Factorial Calculator
Calculate the factorial of any non-negative integer. Also computes permutations (nPr) and combinations (nCr).
Did this tool work for you?
How to use this calculator
Factorial multiplies all positive integers from 1 to n. Permutations count ordered arrangements; combinations count unordered selections.
- 1
Enter n (the main number).
- 2
Enter r to also calculate permutations nPr and combinations nCr.
- 3
Factorial of n gives the number of ways to arrange n distinct items.
- 4
P(n,r) counts ordered selections of r from n; C(n,r) counts unordered.
Frequently asked questions
Why is 0! equal to 1?
There is exactly one way to arrange zero items: do nothing. Defining 0! as 1 also keeps the formula C(n,r) = n! ÷ (r! × (n−r)!) working at the edges, so C(5,0) and C(5,5) both come out as 1. The calculator returns 1 for 0! and also for P(0,0) and C(0,0).
Why does the calculator stop at n = 170?
Results are stored as standard double-precision numbers, whose largest value is about 1.8 × 10³⁰⁸. 170! is roughly 7.2574 × 10³⁰⁶ and fits, but 171! does not, so any n above 170 is rejected with an error rather than shown as Infinity.
Why are large results shown as 8.0658e+67 instead of every digit?
Any result of 1 quadrillion (10¹⁵) or more is displayed with four decimal places in exponent form, for example 52! as 8.0658e+67. Beyond about 9 × 10¹⁵ doubles can no longer hold every integer exactly, so the digits past the first few are approximate. For exact digits of numbers that large you need a big-integer tool.
What is the difference between P(n,r) and C(n,r)?
P(n,r) counts ordered selections, so picking A then B differs from B then A. C(n,r) counts unordered groups, so it equals P(n,r) divided by r!. With n = 10 and r = 3 the calculator gives 720 ordered arrangements but only 120 groups, because each group of three can be ordered in 3! = 6 ways.
What happens if r is larger than n?
You get an error, because you cannot pick more distinct items than exist. When r equals n, P(n,n) is the same as n! and C(n,n) is 1. When r is 0, both P and C are 1.
Can I enter a decimal or negative number?
No. Both n and r must be whole numbers; entries such as 5.5 return an error instead of being rounded. Negative n is rejected too. The factorial can be extended to non-integers with the gamma function, but this calculator does not do that.
Does it handle repeated items or selections with replacement?
No. P(n,r) and C(n,r) here assume every item is distinct and nothing is put back. Arrangements with repeated letters, such as the word LEVEL, need n! divided by the factorials of the repeat counts, and selections with replacement use different formulas such as nʳ for ordered choices.
Factorial, permutation and combination calculator
What n! counts
The factorial n! is the product of every whole number from 1 up to n, and it counts the ways to put n different items in a row. Three books can be shelved in 3! = 6 orders, eight runners can finish a race in 8! = 40,320 orders. By definition 0! = 1. The same engine gives P(n,r) = n! ÷ (n−r)! for ordered picks and C(n,r) = n! ÷ (r!(n−r)!) for unordered picks.
| n | n! |
|---|---|
| 5 | 120 |
| 8 | 40,320 |
| 12 | 479,001,600 |
| 15 | 1,307,674,368,000 |
| 20 | 2.4329e+18 |
| 50 | 3.0414e+64 |
| 100 | 9.3326e+157 |
Worked example: a five-card poker hand
How many different five-card hands exist in a 52-card deck? Order in your hand does not matter, so use combinations. Entering n = 52 and r = 5 returns C(52,5) = 2,598,960. The ordered figure P(52,5) is 311,875,200, which is 120 times larger, and 120 is 5!, the number of ways to reorder the same five cards. Seeing both numbers side by side is the quickest way to check whether a problem calls for P or C.
Worked example: a 6-from-49 lottery draw
A game where you pick six numbers from 49 and order is irrelevant has C(49,6) = 13,983,816 possible tickets, so a single ticket matches the jackpot combination with probability 1 in 13,983,816. If order mattered, there would be P(49,6) = 10,068,347,520 outcomes. Because the calculator multiplies only the six terms it needs rather than dividing two huge factorials, these results stay exact for values below the display cutoff.
Choosing between P and C
Ask one question: would swapping two chosen items give a different outcome? Assigning gold, silver and bronze medals to 25 athletes is ordered, so P(25,3) = 13,800. Choosing a three-person committee from the same 25 people is unordered, so C(25,3) = 2,300. The ratio is always r!, here 6. If the same item can be chosen twice, or some items are identical, neither formula applies directly.
Range and rounding
Accepted inputs are whole numbers with 0 ≤ r ≤ n ≤ 170. Results below 10¹⁵ print as full integers with thousands separators, and anything larger prints in exponent form with five significant figures. Treat exponent-form values as approximations: they are accurate to roughly 15 to 16 significant digits at best, which is the limit of the number type, not of the mathematics.
Learn more from an authoritative source:
WikipediaTriangle Calculator
Calculate the area, perimeter, angles, and height of a triangle from three sides using Heron's formula.
Circle Calculator
Calculate the area, circumference, diameter, and arc length of a circle from radius, diameter, or circumference.
Pythagorean Theorem Calculator
Calculate any side of a right triangle using the Pythagorean theorem. Solve for hypotenuse or either leg.
Logarithm Calculator
Calculate logarithms in any base — common (base 10), natural (base e), binary (base 2), or custom base.
Exponent Calculator
Calculate any base raised to any power. Handles large exponents, fractional powers (roots), and negative exponents.
Linear Equation Solver
Solve a system of two linear equations with two unknowns using substitution or Cramer's rule.
Results are estimates for informational purposes only and do not constitute professional financial, medical, legal, or technical advice. Read full disclaimer →