CalSolve

Factorial Calculator

Calculate n! exactly up to n = 3,000 and approximately up to 100,000, with its number of digits, its trailing zeros and its scientific notation.

20!

2,432,902,008,176,640,000

Number of digits
19
Trailing zeros
4
Scientific notation
2.432902 × 10¹⁸

About this tool

The factorial of a whole number n, written n!, is the product of all whole numbers from 1 to n: 5! = 5 × 4 × 3 × 2 × 1 = 120. By convention, 0! = 1. Factorials grow faster than any power: 10! = 3,628,800, 20! = 2,432,902,008,176,640,000 already has 19 digits, and 70! ≈ 1.197857 × 10¹⁰⁰ is the first factorial larger than a googol.

Factorials count arrangements: 5 books can be lined up on a shelf in 5! = 120 different orders, and a deck of 52 cards can be shuffled in 52! ≈ 8.065818 × 10⁶⁷ ways, a 68-digit number. They're also the basis of combinations, C(n, k) = n! / (k! × (n − k)!): there are C(49, 6) = 13,983,816 ways to choose 6 numbers out of 49 in a lottery.

The calculator computes n! exactly with arbitrary-precision integers up to n = 3,000, a 9,131-digit number you can copy in full. Above that, up to 100,000, it uses logarithms to give the number of digits and the scientific notation. Trailing zeros come from factors 2 × 5 and are counted with Legendre's formula: 100! ends with 100/5 + 100/25 = 24 zeros.

Worked example

  1. 1Enter a whole number n from 0 to 100,000.
  2. 2Read n!, its number of digits, its trailing zeros and its scientific notation.
  3. 3For n up to 3,000, display and copy the exact value. Example: 13! = 6,227,020,800.

Formula

n! = n × (n − 1) × … × 2 × 1 ; 0! = 1 ; trailing zeros = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + … ; Stirling: n! ≈ √(2πn) × (n/e)ⁿ

Related tools

Frequently asked questions

Why is 0! equal to 1?
Because of the rule n! = n × (n − 1)!: for n = 1, 1! = 1 × 0!, so 0! must equal 1. It's also the number of ways to arrange an empty set (exactly one: leave it as it is), and it keeps formulas such as C(n, 0) = 1 consistent.
How many trailing zeros does 1000! have?
249, since 1000/5 + 1000/25 + 1000/125 + 1000/625 = 200 + 40 + 8 + 1, rounding each quotient down. Each zero comes from a factor 10 = 2 × 5, and there are always more factors of 2 than of 5.
What is Stirling's formula?
An approximation of n! for large n: n! ≈ √(2πn) × (n/e)ⁿ. For n = 10 it gives 3,598,696, only 0.83% below the exact 3,628,800, and the relative error keeps shrinking as n grows.
Can you take the factorial of a decimal or negative number?
Not with n!, which is only defined for the whole numbers 0, 1, 2 and so on. The gamma function extends it to decimals, with Γ(n + 1) = n!, for example Γ(1.5) = √π / 2 ≈ 0.886227, but it isn't defined for negative whole numbers.