The factorial function is represented by the exclamation point **!** and is a mathematical function that returns the product of all positive integers less than or equal to a given number.

For example, the factorial of 5 is 5! = 5*4*3*2*1 = 120. You can more quickly calculate the factorial of a number in R using the **factorial()** function.

This guide shows how to calculate the factorial of a number in R.

#### Syntax

`factorial(x)`

#### Arguments

**x**= the number whose factorial you want to calculate

### Example: Using factorial() function to calculate the factorial of 12

Type the following into the R console:

`factorial(12)`

#### Output

`[1] 479001600`