Factorial calculator
Enter a whole number, get its factorial.
What is a factorial?
n! is the product of all whole numbers from 1 to n: 5! = 5 × 4 × 3 × 2 × 1 = 120. It counts the ways to arrange n different things in order.
What is 0 factorial?
0! = 1 by definition — there is exactly one way to arrange nothing, and it keeps formulas like n! = n × (n − 1)! working.
How big do factorials get?
Very fast: 10! is 3,628,800, 20! is 2,432,902,008,176,640,000, and 100! has 158 digits. The calculator gives exact values up to 5,000!.
How many ways can a deck of cards be shuffled?
52! ≈ 8.0658 × 10⁶⁷ — a 68-digit number.
Why does 100! end in 24 zeros?
Each zero needs a factor of 10 = 2 × 5, and fives are the scarcer: 100 ÷ 5 = 20 multiples of 5, plus 100 ÷ 25 = 4 that give an extra 5. 20 + 4 = 24.
How many digits does n! have?
The exact count comes from writing the number out: 10! has 7 digits, 100! has 158, 1,000! has 2,568 and 5,000!, the largest the calculator accepts, has 16,326. The counts for 10, 100 and 1,000 agree with the table in Wolfram MathWorld.
Can I take the factorial of a fraction or a negative number?
Not with the product definition, which needs a whole number n ≥ 0, and the calculator accepts only whole numbers from 0 to 5,000. The gamma function extends the idea: n! = Γ(n + 1) for whole n, and (1/2)! = √π ÷ 2 ≈ 0.8862. At negative whole numbers the extension has no value (Wolfram MathWorld, “Factorial”).
Is there a formula that estimates n! for large n?
Stirling’s approximation, n! ≈ √(2πn) × (n ÷ e)ⁿ, follows from NIST DLMF Eq. 5.11.3. It comes out a little low: by 0.8% at n = 10, 0.33% at n = 25 and 0.083% at n = 100, close to 1 ÷ (12n), the first correction term in MathWorld’s series.
How the calculator works
The factorial of a whole number n is n × (n − 1) × … × 2 × 1, so n! = n × (n − 1)!. Setting 0! = 1 keeps that rule working all the way down, and MathWorld gives the counting reason: there is exactly one way to arrange zero objects. The product is multiplied out in exact whole-number arithmetic, so no digits are lost. A 64-bit floating-point number cannot do that: 170! is about 7.257 × 10³⁰⁶, the largest factorial that fits, and 171! overflows to infinity. Trailing zeros come from factors of 5, since 2s are plentiful: their count is ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + … (MathWorld).
Worked example: 25!
Multiplying 25 × 24 × … × 1 gives 15511210043330985984000000, which has 26 digits. The zero count is ⌊25/5⌋ + ⌊25/25⌋ = 5 + 1 = 6, the six zeros at the end of the number. Stirling’s formula gives √(50π) × (25 ÷ e)²⁵ = 1.5460 × 10²⁵, about 0.33% below the exact value. In the short form the calculator shows for long results, 25! = 1.5511 × 10²⁵.
Common mistakes
Treating 0! as 0 instead of 1. Counting only ⌊n/5⌋ zeros and forgetting the extra fives in 25, 125 and so on: 25! has 6 zeros, not 5. Confusing n! with nⁿ or with n² (5! is 120, not 25 or 3,125). Reading n!! as (n!)!: it is the double factorial, a different function.
Sources: Wolfram MathWorld, “Factorial”; NIST Digital Library of Mathematical Functions, section 5.11 (Stirling’s approximation, Eq. 5.11.3). Related tools: permutation and combination calculator, Pascal’s triangle calculator, scientific notation calculator and prime number calculator. How we check our calculators.