How to use the factorial calculator
- Enter a non-negative integer n in the first field.
- Optionally enter r if you also need permutations or combinations.
- The factorial calculator updates instantly as you type.
- Read
n!,n!!, and when r is provided,P(n,r)andC(n,r)below.
How n factorial works
The factorial of a non-negative integer n, written as n!, is the product of all positive integers from 1 up to n. By convention, 0! equals 1.
For example, to calculate factorial 5: 5! = 5 x 4 x 3 x 2 x 1 = 120. The value grows extremely fast. By the time you reach 20!, the result is 2,432,902,008,176,640,000. Because standard JavaScript numbers lose integer precision beyond 253, this tool uses BigInt internally to keep every digit exact regardless of size.
Double factorial explained
The double factorial, written n!!, multiplies every second integer down to 1 or 2. For odd n it steps by 2 through odd numbers; for even n it steps through even numbers.
Examples:
7!! = 7 x 5 x 3 x 1 = 1058!! = 8 x 6 x 4 x 2 = 3840!! = 1and1!! = 1by definition.
Double factorials appear in combinatorics, series expansions and certain physics formulas where alternating products are needed.
Permutations and combinations
When you provide both n and r, the tool acts as a permutation calculator and combination calculator at once.
Permutations P(n, r) count ordered arrangements of r items chosen from n distinct items. The formula is P(n, r) = n! / (n - r)!. For instance, choosing 3 officers from 10 candidates gives P(10, 3) = 10! / 7! = 720.
Combinations C(n, r) count unordered selections. The formula is C(n, r) = n! / (r! x (n - r)!). A classic example is a five-card poker hand from a 52-card deck: C(52, 5) = 2,598,960.
Both require that r is between 0 and n inclusive. If r exceeds n, no valid selection exists and the tool returns an error.
Reference table of common factorials
Here are frequently used values so you can verify your own work without running the calculator each time.
| n | n! | n!! |
|---|---|---|
| 0 | 1 | 1 |
| 1 | 1 | 1 |
| 2 | 2 | 2 |
| 3 | 6 | 3 |
| 4 | 24 | 8 |
| 5 | 120 | 15 |
| 6 | 720 | 48 |
| 7 | 5,040 | 105 |
| 8 | 40,320 | 384 |
| 10 | 3,628,800 | 3,840 |
| 12 | 479,001,600 | 46,080 |
Common mistakes to avoid
A few pitfalls come up often when people calculate factorial values by hand or with basic calculators.
- Forgetting 0! = 1. Zero factorial is defined as 1, not 0. This keeps formulas like C(n, 0) = 1 consistent.
- Confusing n! with n!!. The double factorial skips every other number, so 6!! is 48, not 720.
- Using floating-point math for large n. Standard 64-bit floats cannot represent integers exactly above about 9 x 1015. Always use arbitrary-precision arithmetic (BigInt) for exact results.
- Mixing up permutations and combinations. Order matters for P(n, r) but not for C(n, r). Choosing a president and vice-president is a permutation; choosing two committee members is a combination.
Worked examples
Each result below was produced by the same code the tool runs, so you can check your own numbers against them.
| Example | Input | Result |
|---|---|---|
| 5 factorial | n: 5 | n! (5!): 120; n!! (5!!): 15 |
| Permutations P(10,3) | n: 10; r (for nPr and nCr): 3 | n! (10!): 3,628,800; n!! (10!!): 3,840; P(10, 3): 720; C(10, 3): 120 |
| Combinations C(52,5) | n: 52; r (for nPr and nCr): 5 | n! (52!): 80,658,175,170,943,878,571,660,636,856,403,766,975,289,505,440,883,277,824,000,000,000,000; n!! (52!!): 27,064,431,817,106,664,380,040,216,576,000,000; P(52, 5): 311,875,200; C(52, 5): 2,598,960 |
| Double factorial 9!! | n: 9 | n! (9!): 362,880; n!! (9!!): 945 |
FAQ
What is 0 factorial?
0! is defined as 1. This convention ensures that formulas involving combinations and permutations remain consistent when selecting zero items.
Can I calculate the factorial of a negative number?
No. The standard factorial function is only defined for non-negative integers. For negative or fractional arguments, mathematicians use the Gamma function instead.
What is the difference between n! and n!!?
n! multiplies every integer from 1 to n. n!! (double factorial) multiplies every second integer, so 7!! = 7 x 5 x 3 x 1 = 105.
When should I use permutations vs combinations?
Use permutations (nPr) when the order of selection matters, such as arranging books on a shelf. Use combinations (nCr) when order does not matter, such as picking lottery numbers.
Why does the result have commas?
Large factorials produce very long numbers. Commas are added as thousands separators to make them easier to read. The underlying value is exact.
How large an input can this factorial calculator handle?
The tool accepts values up to 10,000. Because it uses BigInt arithmetic, every digit of the result is exact, though extremely large outputs may take a moment to render.