Factorial Calculator

Factorial Calculator
Tip: 0! = 1. Exact results can be very long; use “Save .txt”.

Factorial Calculator (n!) – Exact Values, Approximations & Steps

Use this guide to understand and compute factorials. See the definition of n!, a quick reference table, fast methods for large factorials (scientific notation & Stirling’s approximation), how to find trailing zeros in n!, and how factorials power permutations and combinations.

What is a factorial?

  • For a non-negative integer n, the factorial n! is the product of all positive integers up to n:

    • 0! = 1 (by definition)

    • 1! = 1

    • n! = n × (n−1) × (n−2) × … × 2 × 1 for n ≥ 1

    Examples:
    3! = 3×2×1 = 6 ·· 5! = 5×4×3×2×1 = 120

How to calculate n! (step by step)

  1. Start at n and multiply downwards by each whole number.

  2. Stop at 1.

  3. If n = 0, return 1.

Tip: Factorials grow very quickly. Even 20! is a 19-digit number.

Quick factorial table (0–20)

  1. 0! = 1

  2. 1! = 1

  3. 2! = 2

  4. 3! = 6

  5. 4! = 24

  6. 5! = 120

  7. 6! = 720

  8. 7! = 5,040

  9. 8! = 40,320

  10. 9! = 362,880

  11. 10! = 3,628,800

  12. 11! = 39,916,800

  13. 12! = 479,001,600

  14. 13! = 6,227,020,800

  15. 14! = 87,178,291,200

  16. 15! = 1,307,674,368,000

  17. 16! = 20,922,789,888,000

  18. 17! = 355,687,428,096,000

  19. 18! = 6,402,373,705,728,000

  20. 19! = 121,645,100,408,832,000

  21. 20! = 2,432,902,008,176,640,000

Large factorials: digits, scientific notation & Stirling’s approximation

Because n! explodes in size, we often present big results as mantissa × 10^exponent.

  • Digits in n! (Kamenetsky/Stirling-based):
    digits ≈ ⌊ n·log₁₀(n/e) + 0.5·log₁₀(2πn) ⌋ + 1
    (Accurate for n ≥ 3; use 1 digit for n = 0 or 1.)

  • Stirling’s approximation (natural log form):
    ln(n!) ≈ n·ln n − n + ½·ln(2πn)
    Then: n! ≈ e^{ln(n!)} ≈ m × 10^k with
    k = ⌊ ln(n!) / ln 10 ⌋ and m = 10^{ ln(n!)/ln 10 − k }.

These give reliable scientific-notation estimates (e.g., 100! ≈ 9.3326 × 10^157).

Trailing zeros in n!

The number of trailing zeros in n! equals the number of times 10 divides n!, which is limited by the number of factor 5s (since 2s are plentiful):

zeros(n!) = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + ⋯

Examples:

  • zeros(10!) = ⌊10/5⌋ = 2

  • zeros(100!) = ⌊100/5⌋ + ⌊100/25⌋ = 20 + 4 = 24

Factorials in permutations & combinations

  • Permutations (order matters):
    P(n, r) = n! / (n−r)!

  • Combinations (order doesn’t matter):
    C(n, r) = n! / (r! · (n−r)!)

Examples:

  • P(10, 3) = 10! / 7! = 720

  • C(10, 3) = 10! / (3!·7!) = 120

FAQs

Q: What is 0! and why is it 1?
Defining 0! = 1 keeps combinatorics identities (like C(n, 0) = 1) and recurrence relations consistent.

Q: How big does n! get?
Very fast. 50! has 65 digits; 100! has 158 digits. Use scientific notation and logs for large n.

Q: Can I compute factorials for non-integers?
Yes, via the Gamma function: Γ(z) generalises factorial with n! = Γ(n+1) for integers n ≥ 0. Most calculators stick to integers for simplicity.

Q: How do I find trailing zeros without computing n!?
Use the factor-of-5 formula above—no huge products required.

Q: What’s the fastest way to estimate n!?
Use Stirling’s approximation for ln(n!), then convert to scientific notation.

Q: Why does my calculator show “Infinity” for big n?
Standard floating-point overflows. Use big-integer arithmetic (exact) or logarithms/approximations (estimate).

Was this calculator helpful?

Rate your experience to help us improve.

Thanks for rating! See the average and total ratings above.

Not rated yet—be the first to rate this calculator.