Calculating A Factorial in R

There is a simple function available for calculating a factorial in R.

The function can accept a numeric value or a vector of numeric values.

# factorial in R

> factorial(3)
[1] 6

> factorial(5)
[1] 120

> factorial(8)
[1] 40320

> factorial (c(3,4,5))
[1]   6  24 120