Factorial Calculator — Free n! Calculator with Step-by-Step | AllInOneTools
n! Math Calculator

Factorial Calculator

Calculate n! for any non-negative integer. See the step-by-step multiplication chain, digit count, trailing zeros, scientific notation, and a factorial growth chart.

number
! =
3,628,800
📑 Step-by-Step Multiplication
📈 Factorial Growth (log scale)
📚 Common Factorials Reference
nn!DigitsTrailing 0s

Factorials: The Building Blocks of Combinatorics

The factorial of a non-negative integer n, written as n!, is the product of all positive integers from 1 to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. By convention, 0! = 1, which may seem surprising but is essential for combinatorial formulas to work correctly. Factorials grow extraordinarily fast — so fast that 170! is the largest factorial that fits in a standard floating-point number, and 100! has 158 digits. Factorials are fundamental to permutations, combinations, probability, Taylor series, and many areas of mathematics and computer science.

Factorial Formulas and Properties

Definition: n! = n x (n-1) x (n-2) x ... x 2 x 1
Convention: 0! = 1, 1! = 1

Recursive: n! = n x (n-1)!

Stirling's Approximation (large n):
  n! ~ sqrt(2*pi*n) x (n/e)^n

Trailing Zeros (from factors of 5):
  zeros = floor(n/5) + floor(n/25) + floor(n/125) + ...

Log of Factorial:
  log10(n!) = sum of log10(k) for k=1 to n
  Digits in n! = floor(log10(n!)) + 1

Related Functions:
  Permutation: P(n,r) = n! / (n-r)!
  Combination: C(n,r) = n! / (r!(n-r)!)
  Gamma: n! = Gamma(n+1) for integers

Applications of Factorials

Factorials appear wherever you count arrangements. The number of ways to arrange n distinct objects in a row is n!. In probability, the binomial coefficient C(n,k) = n!/(k!(n-k)!) counts how many ways to choose k items from n. Taylor series use factorials in denominators: ex = ∑ xn/n!. In cryptography, the security of certain systems depends on the enormous size of factorials. Computer science uses factorials in algorithm analysis — algorithms with O(n!) complexity are considered intractable for large n because factorial growth outpaces exponential growth.

Why Does 0! = 1?
There is one way to arrange zero objects: do nothing. This is the "empty arrangement." More formally, the recursive definition n! = n × (n-1)! requires 0! = 1 for 1! = 1 × 0! to be consistent. It also ensures that C(n,0) = n!/(0! × n!) = 1, which correctly represents one way to choose nothing.

Frequently Asked Questions

What is a factorial?
n! (n factorial) is the product of all positive integers from 1 to n. Example: 5! = 5 x 4 x 3 x 2 x 1 = 120. It counts the number of ways to arrange n distinct objects.
Why is 0! equal to 1?
By convention and mathematical necessity. There is exactly one way to arrange zero items (the empty arrangement). It also makes recursive formulas and combinatorial identities work correctly.
How fast do factorials grow?
Extremely fast — faster than exponential. 10! = 3.6 million, 20! = 2.4 quintillion, 100! has 158 digits. 170! is the largest that fits in a 64-bit float (~10^306).
What are trailing zeros in a factorial?
Trailing zeros come from factors of 10 = 2 x 5. Since there are always more 2s than 5s, count factors of 5: floor(n/5) + floor(n/25) + floor(n/125) + ... Example: 100! has 24 trailing zeros.
Can you take the factorial of a decimal?
Not directly with n!, but the Gamma function extends factorials to all complex numbers: x! = Gamma(x+1). For example, (1/2)! = sqrt(pi)/2 = 0.8862...
What is Stirling's approximation?
An estimate for large factorials: n! approx sqrt(2*pi*n) * (n/e)^n. It becomes very accurate for large n. Used when exact computation is impractical.