You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
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 |