🧮PantoCalc

Factorial Calculator

Calculate n!, double factorial, and subfactorial

How Factorial Calculation Works

Formula

n! = n × (n-1) × (n-2) × ... × 2 × 1

  1. 1Enter a non-negative integer n.
  2. 2The factorial n! is the product of all positive integers from 1 to n.
  3. 3For example, 5! = 5 × 4 × 3 × 2 × 1 = 120.
  4. 4Double factorial n!! multiplies every other number: 5!! = 5 × 3 × 1 = 15.
  5. 5Subfactorial !n counts derangements (permutations with no fixed points).

About Factorial Calculator

Calculate factorials (n!), double factorials (n!!), and subfactorials (!n). Shows step-by-step multiplication and handles large numbers with scientific notation.

Frequently Asked Questions

What is 0! (zero factorial)?

0! = 1 by definition. This is a convention that makes many mathematical formulas work correctly, including the binomial coefficient and the formula for permutations.

How large can the input be?

JavaScript can handle factorials up to 170! (about 7.26 × 10³⁰⁶). Beyond that, the result exceeds the maximum floating-point number and returns Infinity.

What is a subfactorial?

The subfactorial !n counts the number of derangements of n elements — permutations where no element appears in its original position. For example, !3 = 2.