Home basic programing in r hackerrank R Basics-25 - Coding-Iterations-1 (Hands On) - ClassiCoder Factorial. Write a function Nfact to find the factorial of the number num passed as arguments using the while() loop. The function must return the result.Iterations-1-R-BasicIterations-1-R-Basic-Solution
1 comment
findfactorial <- function(n){
factorial <- 1
if(n==0 | n==1){
factorial <- 1
} else{
while(n >= 1){
factorial <- factorial * n
n <- n-1
}
}
return (factorial)
}