14 lines
225 B
R
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
|