Factorial Calculator
Enter a whole number to get its exact factorial. Big results are computed on your device in a background thread, nothing is uploaded.
Number
Whole numbers from 0 to 50,000.
Calculating…
Exact value
Working
| k | k! = k × (k − 1)! |
|---|
How to use the factorial calculator
Type a whole number n from 0 to 50,000. The exact value of n! appears below, with its number of digits, its trailing zeros and its value in scientific notation. For n up to 20 the working is shown step by step. Use Copy or Save .txt to take the full number with you; large results are worked out in a background thread so the page stays responsive.
Factorial formula
The factorial of n is the product of every whole number from 1 to n: n! = n × (n − 1) × … × 2 × 1, with 0! = 1 by definition. Each factorial follows from the one before: n! = n × (n − 1)!. Factorials count arrangements: n different objects can be ordered in n! ways.
The number of trailing zeros comes from Legendre's formula, which counts the factors of 5 (there are always more factors of 2): zeros = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …
Worked example
5! = 5 × 4 × 3 × 2 × 1. Step by step: 1! = 1, 2! = 2 × 1 = 2, 3! = 3 × 2 = 6, 4! = 4 × 6 = 24, 5! = 5 × 24 = 120. It has 3 digits and ⌊5/5⌋ = 1 trailing zero. For 100!, the trailing zeros are ⌊100/5⌋ + ⌊100/25⌋ = 20 + 4 = 24, and the full value has 158 digits.
FAQ
Why is 0! equal to 1?
There is exactly one way to arrange zero objects (do nothing), and keeping 0! = 1 makes the rule n! = n × (n − 1)! work for n = 1. It is also the empty product, like how a sum of nothing is 0.
Can I take the factorial of a negative number or a decimal?
Not with n!. Factorials are defined for whole numbers 0 and above. The gamma function extends the idea to decimals (Γ(n + 1) = n!), but it is undefined at negative integers.
How many ways can a deck of 52 cards be shuffled?
52! ways, about 8.066 × 10⁶⁷. Try the 52! button above to see all 68 digits.
Are the results exact?
Yes. Every digit is calculated exactly with whole-number arithmetic in WebAssembly, not floating point, and nothing is sent to a server.