> For the complete documentation index, see [llms.txt](https://math-5.gitbook.io/math/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://math-5.gitbook.io/math/reference/mathematical-operations/factorial.md).

# factorial

## Find the factorial of a given number

```cpp
int factorial(n);
```

will return the factorial of a given number. There is no custom return type, the function always returns an integer.&#x20;

```cpp
factorial(5); //120
factorial(0); //1
```

{% hint style="warning" %}
After n = 19, the function doesn't work anymore, as the numbers are too large for the integer sizing. Instead, use factorialL(n) for larger numbers.&#x20;
{% endhint %}
