Factorial Calculator: n!, Double Factorial and Subfactorial

Factorial Calculator

Calculate an exact factorial, double factorial, or subfactorial and inspect its digits, trailing zeros, digit sum, scientific notation, and expansion.


Enter a whole number from 0 to 5,000. The complete exact integer is calculated locally in your browser.


Factorial formulas

The factorial of a nonnegative integer n is the product n!=n×(n−1)×…×2×1, with 0!=1. Factorials count arrangements and appear in combinations, probability, series, and statistics.

The double factorial skips every other integer: n!!=n×(n−2)×(n−4)×…, ending at 2 or 1. The subfactorial !n counts derangements—permutations in which no item remains in its original position.

Checked examples

ExpressionCalculationExact result
0!Definition1
1!11
5!5×4×3×2×1120
10!10×9×…×13,628,800
20!20×19×…×12,432,902,008,176,640,000
8!!8×6×4×2384
9!!9×7×5×3×1945
!0Definition1
!4Derangements of four items9
!6Derangements of six items265

How to use the calculator

  1. Select factorial, double factorial, or subfactorial.
  2. Enter a whole number from 0 to 5,000.
  3. Select Calculate factorial.
  4. Review the exact integer, digit count, trailing zeros, digit sum, and formula.

Limits and interpretation

  • This calculator accepts nonnegative integers only and computes exact values with BigInt.
  • The maximum input is 5,000 to keep computation and display responsive.
  • The complete result can contain thousands of digits; its result box scrolls without truncating the integer.
  • Factorial and double factorial are different operations: 6!=720, while 6!!=48.
  • Subfactorial notation places the exclamation mark before n and counts derangements, not ordinary factorials.

Frequently asked questions

Why is 0! equal to 1?

There is exactly one way to arrange zero objects: the empty arrangement. This convention also keeps factorial formulas consistent.

How many trailing zeros does n! have?

Each trailing zero needs a factor pair 2×5. Factorials contain more twos than fives, so the count is the sum of floor(n/5), floor(n/25), floor(n/125), and so on.

What is the difference between n! and n!!?

Ordinary factorial multiplies every positive integer down to 1. Double factorial multiplies every second integer with the same parity as n.

What does !n mean?

It is the subfactorial or derangement number: the number of permutations in which none of n objects stays in its original position.

Related calculators

Use the Permutation and Combination Calculator for nPr and nCr, the Probability Calculator for event and binomial probabilities, or the Scientific Notation Calculator for very large values.