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

    Frequently Asked Questions

    What is a factorial?

    A factorial (written as n!) is the product of all positive integers from 1 to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120.

    Why is 0! equal to 1?

    By convention and mathematical consistency, 0! = 1. This is needed for formulas like combinations to work correctly: C(n,0) = n! / (0! × n!) = 1.

    Learn More

    Guide

    How to Calculate Probability - Complete Guide

    Learn the fundamentals of probability including basic probability, compound events, conditional probability, Bayes' theorem, and expected value with worked examples.

    Ready to run the numbers?

    Open Factorial Calculator