# R Program to find the factorial of a number

In this program, You will learn how to find the factorial of a number in R.

```
3! = 1 * 2 * 3
4! = 1 * 2 * 3 * 4
5! = 1 * 2 * 3 * 4 * 5
```

## Example: How to find the factorial of a number in R

```
{
x <- as.integer(readline(prompt = "Enter a number :"))
f = 1
for (i in 1:x) {
f = f * i
}
print(paste("Factorial is :", f))
}
```

#### Output:

```
Enter a number :5
[1] "Factorial is : 120"
```