programming-examples/r/Find Factorial of a number using recursion.r
2019-11-18 14:03:28 +01:00

14 lines
225 B
R

Find Factorial of a number using recursion
recur_factorial <- function(n) {
if(n <= 1) {
return(1)
} else {
return(n * recur_factorial(n-1))
}
}
Output
> recur_factorial(5)
[1] 120