Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Factorial of input

- example
`f = factorial(n)`

`f = factorial(`

returns
the product of all positive integers less than or equal to `n`

)`n`

,
where `n`

is a nonnegative integer value. If `n`

is
an array, then `f`

contains the factorial of each
value of `n`

. The data type and size of `f`

is
the same as that of `n`

.

The factorial of `n`

is commonly written in
math notation using the exclamation point character as *n!*.
Note that `n!`

is not a valid MATLAB^{®} syntax
for calculating the factorial of `n`

.

Was this topic helpful?