In this tutorial, we have shared a **r program for factorial using recursion** with the program output. If yo are r beginners or want to start learning R programming then this tutorial will help you understand the R programming better.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # take input from the user num = as.integer(readline(prompt="Enter a number: ")) factorial = 1 # check is the number is negative, positive or zero if(num < 0) { print("Sorry, factorial does not exist for negative numbers") } else if(num == 0) { print("The factorial of 0 is 1") } else { for(i in 1:num) { factorial = factorial * i } print(paste("The factorial of", num ,"is",factorial)) } |

**Output**

1 2 | Enter a number: 8 [1] "The factorial of 8 is 40320" |

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

- Sum of Natural Numbers Using Recursion
- R program to find L.C.M. with the output
- R program to take input from user with the output
- Convert decimal into binary using recursion in R
- Odd or Even program in R programming
- R program to check armstrong number
- R program to find the sum of natural numbers
- r practice problems for beginners
- R Program to Check for Leap Year with the output
- How to Find L.C.M in R Programming with example

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok