Factorial Calculator Formula

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

Formulas Used

Factorial N

factorial_n = factorial(n)

Factorial R

factorial_r = factorial(r)

Permutations

permutations = n >= r ? factorial(n) / factorial(n - r) : 0

Combinations

combinations = n >= r ? factorial(n) / (factorial(r) * factorial(n - r)) : 0

Variables

VariableDescriptionDefault
nn10
rr (for P and C)3

How It Works

Factorial, Permutations, and Combinations

Factorial

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

0! = 1 by convention.

Permutations (order matters)

P(n, r) = n! / (n-r)!

Number of ways to arrange r items from n distinct items.

Combinations (order doesn't matter)

C(n, r) = n! / (r! × (n-r)!)

Number of ways to choose r items from n without regard to order.

Worked Example

Calculate 10!, P(10,3), and C(10,3).

n = 10r = 3
  1. 0110! = 3,628,800
  2. 02P(10,3) = 10!/7! = 10×9×8 = 720
  3. 03C(10,3) = 720/3! = 720/6 = 120

Ready to run the numbers?

Open Factorial Calculator