Factorial Calculator Formula

Understand the math behind the factorial calculator. Each variable explained with a worked example.

Formulas Used

Factorial Val

factorial_val = factorial(n)

N Minus 1 Factorial

n_minus_1_factorial = n > 0 ? factorial(n - 1) : 1

Variables

VariableDescriptionDefault
nNumber (n)7

How It Works

How to Calculate a Factorial

Formula

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

Special cases:

  • 0! = 1 (by definition)
  • 1! = 1
  • Factorials grow extremely fast. 10! = 3,628,800 and 20! = 2,432,902,008,176,640,000.

    Worked Example

    Calculate 7!

    n = 7
    1. 017! = 7 × 6 × 5 × 4 × 3 × 2 × 1
    2. 02= 42 × 5 × 4 × 3 × 2 × 1
    3. 03= 210 × 4 × 3 × 2 × 1
    4. 04= 840 × 3 × 2 × 1
    5. 05= 2520 × 2 × 1
    6. 06= 5040

    Ready to run the numbers?

    Open Factorial Calculator