factorial

n!

factorial(n)

Try it yourself:


Calculate products of integers with factorial

factorial(n), written n!, multiplies every positive integer up to n. Thus 5! equals 120, and 0! is 1. Factorials are fundamental in counting arrangements, probability, and series formulas.

Counting applications

The number of orderings of n distinct objects is n!. For selections, use combinations; for ordered selections, use permutations. These functions avoid manually forming large factorial ratios. gamma extends the factorial idea beyond non-negative integers.

Input limits

For the usual combinatorial meaning, n must be a non-negative integer. Factorials grow extremely quickly, so even moderate inputs produce very large exact integers or can overflow in numeric systems. Avoid converting to ordinary floating point unless an approximation is intended. For logarithmic probability work, lgamma is often more stable.

Try Factorial in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions