TTKTheTextKit

Factorial Calculator

Enter a whole number from 0 to 10,000 and get its factorial n! as an exact number, with the number of digits, the number of trailing zeros, the double factorial n!!, the subfactorial !n and Stirling's approximation with its error. Long results are shown in scientific notation, and you can copy every digit. Everything runs in your browser.

20!
2,432,902,008,176,640,000
2.432902 x 10^18
Digits
19
In the full number
Trailing zeros
4
floor(n/5) + floor(n/25) + floor(n/125) + ...
20!! (double factorial)
3,715,891,200
Every second number, n (n - 2) (n - 4) ...
!20 (subfactorial)
895,014,631,192,902,121
Ways to rearrange n things so none stays in place
Stirling's approximation
2.422787 x 10^18
-0.4158 percent from the exact value

The factorial n! is the product of the whole numbers from 1 to n, so 5! = 120 and 20! = 2,432,902,008,176,640,000. By convention 0! = 1. It counts the ways to put n different things in order, which is why 52! = 8.065818 x 10^67 is the number of orders of a deck of cards. Factorials grow fast: 100! has 158 digits and 170! is about 7.257 x 10^306, near the largest number a double precision float can hold, but this tool uses exact big integers, so you get every digit up to 10,000!. The number of trailing zeros is the number of times 5 divides into it, floor(n/5) + floor(n/25) + floor(n/125) + and so on, so 100! ends in 24 zeros. The double factorial n!! multiplies every second number down from n, so 9!! = 945, and the subfactorial !n counts the arrangements where no item is in its original place, so !4 = 9. Stirling's approximation, the square root of 2 pi n times (n/e) to the n, is always a little low, by about 0.83 percent at n = 10 and 0.083 percent at n = 100. Only whole numbers are covered here. Everything runs in your browser.

Related Tools

[6 suggestions]

About the Factorial Calculator

The factorial n! is the product of the whole numbers from 1 to n, so 5! = 120, 10! = 3,628,800 and 20! = 2,432,902,008,176,640,000, and by convention 0! = 1. It counts the orders in which n different things can be arranged, so the 52 cards of a deck can be ordered in 52! = 8.065818 x 10^67 ways. The numbers grow quickly: 100! has 158 digits, 1,000! has 2,568 and 10,000! has 35,660. A double precision float cannot hold 171! or more, so the tool uses exact big integers and gives every digit. The number of trailing zeros is the number of factors of 5, floor(n/5) + floor(n/25) + floor(n/125) + and so on, so 100! ends in 24 zeros and 1,000! in 249. The double factorial n!! multiplies every second number down from n, so 9!! = 945 and 10!! = 3,840. The subfactorial !n counts the rearrangements of n items in which none stays in its place, called derangements: !4 = 9, !5 = 44 and !10 = 1,334,961. Stirling's approximation, sqrt(2 pi n) (n / e)^n, is always a little below the true value, by about 0.83 percent at n = 10 and 0.083 percent at n = 100, and the relative error shrinks as n grows. Only whole numbers are covered, so there is no factorial of a negative number or a fraction here.

What is a factorial?▾

The factorial n! is 1 x 2 x 3 x ... x n, the product of all the whole numbers up to n. So 5! = 120. It is the number of ways to arrange n different items in a row, and 0! is defined as 1.

Why is 0! equal to 1?▾

There is exactly one way to arrange nothing, the empty arrangement, and it keeps formulas such as n! = n x (n-1)! and the counting of combinations working. It is a convention that fits every use.

How many zeros does n! end with?▾

The number of times 5 divides into it: floor(n/5) + floor(n/25) + floor(n/125) and so on, because each factor of 5 pairs with a factor of 2 to make a 10. For 100! that is 20 + 4 = 24 zeros.

What is the largest factorial this tool can compute?▾

10,000!, which has 35,660 digits. The tool works with exact big integers, so every digit is correct, and it also shows a short form in scientific notation.

What is a subfactorial?▾

The subfactorial !n is the number of ways to rearrange n items so that none ends up in its original place. For 4 items it is 9. It is close to n! divided by e.