findfact=function(n){
factorial=1
if(n<0)
print("Factorial of negative number is not possible")
else if(n == 0)
print("Factorial of 0 is 1")
else{
for(i in 1:n)
factorial=factorial*i
print(paste("Factorial of ",n," is ",factorial))
}
}
n=as.integer(readline("Enter one number to find factorial"))
findfact(n)
To embed this program on your website, copy the following code and paste it into your website's HTML: