Highest Power
The highest power of a prime p that divides n! is given by Legendre’s formula: ⌊n/p⌋ + ⌊n/p²⌋ + ⌊n/p³⌋ + …, summing until pᵏ exceeds n. Each floor term counts the multiples of that power of p hiding in 1, 2, …, n. For example, the power of 3 in 100! is ⌊100/3⌋ + ⌊100/9⌋ + ⌊100/27⌋ + ⌊100/81⌋ = 33 + 11 + 3 + 1 = 48, so 3⁴⁸ divides 100! but 3⁴⁹ does not. A fast mental shortcut: divide n by p, take the quotient, divide that quotient by p again, and keep going — the sum of all the quotients is the answer (this avoids recomputing each power from scratch). Trailing zeros are simply this formula applied to p = 5.
✅ Solved examples
✏️ Practice — try these, take hints as needed
📝 Topic test — 8 questions
Auto-graded with full solutions; saved to your dashboard. Use the calculator and formula sheet (top-right) any time.
Formula Reference Sheet
Core definitions & identities
| Factorial | n! = 1 × 2 × 3 × … × n |
|---|---|
| Empty product | 0! = 1! = 1 |
| Recurrence | n! = n × (n − 1)! |
| Ratio of factorials | n! / (n − r)! = n(n−1)…(n−r+1) |
| Combination | ⁿCᵣ = n! / [r!(n − r)!] |
Power & zero-counting tools
| Highest power of prime p in n! (Legendre) | ⌊n/p⌋ + ⌊n/p²⌋ + ⌊n/p³⌋ + … |
|---|---|
| Trailing zeros of n! | ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + … |
| Power of composite (e.g. 6 = 2×3) | min of the prime-factor powers in n! |
| Power of pᵏ (e.g. 9 = 3²) | ⌊ (power of p in n!) / k ⌋ |
| Quick count of multiples of m up to n | ⌊n/m⌋ |