Ultra Calculator
    Maths

    Factorial Calculator

    To work out a factorial, multiply every whole number from 1 up to n: 5! = 5 × 4 × 3 × 2 × 1 = 120. By definition 0! = 1. Enter n to get n! for any whole number up to 170, in full up to 17! and in scientific notation above that.

    Last updated by Ultra Calculator

    Factorial

    How to calculate it

    n! = n × (n - 1) × (n - 2) × ... × 2 × 1
    n
    the whole number you enter
    n!
    n factorial, the product of every whole number from 1 to n

    0! = 1 by definition. For positive n, the optional comparison uses Stirling's approximation, n! ≈ √(2πn) × (n/e)^n, where e ≈ 2.71828.

    Worked example

    5 factorial

    5! = 5 × 4 × 3 × 2 × 1 = 120, a 3-digit number.

    You enter
    Number (n)5
    Compare with Stirling's approximationNo
    The calculator returns
    Factorial (n!)120
    Scientific notation120
    Number of digits3
    Working5! = 5 × 4 × 3 × 2 × 1 = 120

    How to use this calculator

    1. Enter a whole number from 0 to 170 in Number (n).
    2. Choose Yes under Compare with Stirling's approximation if you want the estimate and its error.
    3. Read the result in the Factorial (n!) row. Up to 17! it appears in full; above that it switches to scientific notation.
    4. Check Number of digits. For n of 10 or less, the Working row also writes out the full multiplication.

    Frequently asked questions

    How do you calculate a factorial?

    Multiply all the whole numbers from 1 to n. For example, 6! = 6 × 5 × 4 × 3 × 2 × 1 = 720. Each factorial is the previous factorial multiplied by n, so 7! = 7 × 720 = 5,040.

    Why is 0! equal to 1?

    There is exactly one way to arrange zero objects: leave them as they are. The rule n! = n × (n - 1)! also gives 1! = 1 × 0!, which only holds if 0! = 1. This definition keeps formulas such as nCr = n! ÷ (r! × (n - r)!) correct when r is 0 or n.

    What is the largest factorial this calculator can work out?

    170!, which is about 7.257416e+306 and has 307 digits. 171! exceeds the largest value a standard double-precision number can hold, about 1.8 × 10^308, so the input stops at 170.

    Can you find the factorial of a negative number or a decimal?

    The ordinary factorial is defined only for whole numbers from 0 upwards. Mathematicians extend it to other values with the gamma function, where Γ(n + 1) = n!, but this calculator does not compute that function. Enter a decimal and the calculator asks for a whole number instead.

    How accurate is Stirling's approximation?

    For positive n, its relative error is close to 1 ÷ (12n). The calculator shows 0.83% at n = 10 and 0.42% at n = 20, and the error falls below 0.1% from n = 84. The estimate is always slightly lower than the true factorial.

    How many digits does 100! have?

    100! has 158 digits and is about 9.332622e+157. Enter 100 and the Number of digits row shows 158.

    Learn more

    What a factorial counts

    n! counts the different orders in which n distinct items can be lined up. Three books on a shelf can go in 3! = 6 orders: three choices for the first slot, two for the second and one for the last.

    How quickly factorials grow

    Each step multiplies by a bigger number, so factorials soon exceed powers such as 2^n: n! is larger from n = 4. 10! is 3,628,800, 20! is about 2.4 × 10^18, and 52!, the number of ways to shuffle a deck of cards, is about 8.07 × 10^67.

    Factorials in permutations and combinations

    The number of ordered arrangements of r items from n is n! ÷ (n - r)!, and the number of unordered selections is n! ÷ (r! × (n - r)!). Shared terms cancel, which is why 52! ÷ 50! is simply 52 × 51 = 2,652.

    • Counting the possible orders of a playlist, a queue or a seating plan
    • Checking homework on permutations, combinations and probability
    • Finding how many ways a deck of cards can be shuffled (52!)
    • Counting the orders a brute-force search would have to try
    • Comparing a factorial with Stirling's estimate in a statistics or physics course

    Taking 0! to be 0

    0! is 1. Using 0 makes formulas such as nCr divide by zero when r equals n.

    Adding instead of multiplying

    5! is 5 × 4 × 3 × 2 × 1 = 120. The sum 1 + 2 + 3 + 4 + 5 = 15 is a different quantity, called a triangular number.

    Reading e+18 as a small number

    2.432902e+18 means 2.432902 × 10^18, a number with 19 digits. Check the Number of digits row if in doubt.

    Dividing factorials the long way

    10! ÷ 8! is not (10 ÷ 8)!. Cancel the shared terms: 10! ÷ 8! = 10 × 9 = 90.

    • When a formula divides one factorial by another, cancel first: 52! ÷ 50! = 52 × 51.
    • If you need selections rather than orders, the combination calculator does the division for you.
    • For exact digits of factorials above 17!, use software that works with arbitrary-precision integers.

    Methodology and sources

    n must be a whole number from 0 to 170. The calculator multiplies 1 × 2 × ... × n using standard double-precision arithmetic, with 0! = 1 by definition. Results below 10^15, up to 17!, are shown in full with digit grouping. From 18!, results are shown in scientific notation to 7 significant figures. Double precision keeps about 15 to 17 significant digits, so the last digits of a large factorial may not be exact. The digit count comes from log10 of the result. Stirling's estimate is √(2πn) × (n/e)^n for n of 1 or more, and its error is the gap as a percentage of n!, rounded to 2 decimal places. The Working row writes out every term for n up to 10. The input stops at 170 because 171! is too large for a double.