Factorial Calculator
n!, double factorial, permutations nPr, combinations nCr and derangements, exact for big numbers, with digits and trailing zeros.
How it works
Pick what you need and type n (and r for permutations and combinations). All answers are exact, using big-integer maths, up to n = 3000.
n! multiplies 1 x 2 x ... x n. The double factorial n!! multiplies every second number down from n. nPr counts ordered selections, nCr counts unordered ones. A derangement !n counts ways to rearrange n items so that none stays in its place.
The formula
n! = n x (n-1) x ... x 1. nCr = n! / (r! (n-r)!). nPr = n! / (n-r)!
Worked example
5! = 120. 10 choose 3 = 120 and 10 pick 3 = 720 (nPr is nCr times 3! = 6). 4 derangements: !4 = 9. 100! has 158 digits and 24 trailing zeros.
Good to know
- Trailing zeros of n! = n/5 + n/25 + n/125 ... (rounded down each time), because every zero needs a factor 5 and a factor 2.
- For quick estimates the Stirling approximation sqrt(2 pi n) (n/e)^n is shown with its error.
- 0! = 1 by definition.
Common questions
- Why is 0! equal to 1?
- There is exactly one way to arrange nothing, and it keeps formulas like nCr working.
- What is the largest n?
- 3000 for n!. For nPr and nCr, n up to 3000 with r up to n.
- What is the difference between permutation and combination?
- Order matters in a permutation (a race podium) and not in a combination (a team).
- What is a derangement used for?
- The "letters in wrong envelopes" problem. The chance approaches 1/e, about 36.8%.
More in Utilities.
Find the date that is some days, weeks, months, years or working days from a date, and see the weekday and week number.
OPEN →Age CalculatorYour exact age in years, months and days, the day you were born, your next birthday, and the age gap with another person.
OPEN →Area ConverterConvert square metres, square feet, acres, hectares and more.
OPEN →