Factorial Calculator

Calculate factorial of an integer and apply it to permutation and combination problems

How to Use the Factorial Calculator

This calculator instantly computes n! and, when r is provided, also calculates permutations nPr and combinations nCr. It covers all the basics needed for combinatorics and probability problems.

Factorial Basics

The factorial n! is the product of all positive integers from 1 to n. Example: 5! = 120. By definition, 0! = 1. Factorials grow extremely fast — 20! has 19 digits and 170! is about 7×10³⁰⁶.

Permutations and Combinations

Permutation nPr = n!/(n−r)!: the number of ordered arrangements of r items from n. Combination nCr = n!/(r!(n−r)!): the number of unordered selections. nCr = nPr ÷ r!.

Calculation Range

Exact integer results are guaranteed for n ≤ 20. For n = 21 to 170, values are shown in scientific notation as floating-point approximations. n > 170 overflows 64-bit floating point and is not supported.

Frequently Asked Questions

When do I use permutation vs. combination?

Use permutation when order matters (e.g., PIN codes, race rankings). Use combination when order doesn't matter (e.g., team selection, lottery numbers).

Why is 0! defined as 1?

It's a convention that makes formulas consistent. For instance, nC0 = 1 (one way to choose nothing), which requires 0! = 1. Without it, many combinatorics formulas would break.

Can r be larger than n?

No. You can't choose more items than exist. The constraint r ≤ n is required. When r = n, nPn = n! and nCn = 1.