Factorial calculator
Factorials get enormous fast. 100! has 158 digits, and every one of them is shown here rather than collapsing to a float.
n!
2.43290200817664e+18
- Number of digits
- 19
- (n-1)!
- 1.21645100408832e+17
- Trailing zeros One for every factor of five in the product.
- 4
Show the working
- n = 20
- n! = fact(20) = 2.4329e+18
- Number of digits = 2.4329e+18 > 0 ? floor(log10(2.4329e+18)) + 1 : 1 = 19
- (n-1)! = 20 > 0 ? fact(20-1) : 1 = 1.21645e+17
- Trailing zeros = floor(20/5) + floor(20/25) + floor(20/125) + floor(20/625) + floor(20/3125) = 4
Values are shown to six significant figures here; the arithmetic itself runs on exact fractions and is only rounded where a number is printed.
Scenarios & local history
Compare a saved scenario
Recent calculations
The formula
- n! = 1 x 2 x 3 x ... x n, with 0! = 1
- Trailing zeros = floor(n/5) + floor(n/25) + floor(n/125) + ...
20! is 2 432 902 008 176 640 000, the largest factorial that fits in a 64-bit signed integer.