Factorials and Trailing Zeros in CAT: 3 Prime Power Rules

Questions on trailing zeros of a factorial look like a different topic every time. One asks for the zeros at the end of 100 factorial. Another asks for the highest power of 12 that divides 30 factorial. A third asks for the smallest n whose factorial ends in a given number of zeros.
All of them are one idea in three outfits: count how many times a prime appears in n factorial, then combine the counts. This guide gives three prime power shortcuts, the formula behind them, and the one trap in reverse problems that catches careful students. Every number below was verified by direct calculation.
Factorials live inside Number System, so after you finish this guide, go to practice Number System questions and try the mixed set.
- A trailing zero comes from a factor of 10, which needs one 2 and one 5, and in n factorial the 5s are the scarce ones.
- The number of times a prime p divides n factorial is n divided by p, plus n divided by p squared, and so on, taking the whole number part each time.
- For a composite divisor such as 12, split it into prime powers, count each prime, divide by its exponent, and take the smallest result.
- In reverse problems, the count of zeros jumps at multiples of 25, 125 and so on, so some zero counts are impossible.
- Always test the final answer with a nearby value of n before you mark it.
Why Trailing Zeros Come From Fives
A trailing zero is a factor of 10, and 10 is 2 times 5. To get a zero at the end of n factorial, you need a pair made of one 2 and one 5 in its prime factorisation. Among the numbers from 1 to n, even numbers come far more often than multiples of 5, so the 2s are plentiful and the 5s run out first.
That is why trailing zeros are decided by the number of 5s. You do not have to count both and compare in the case of 10. You count the 5s, and the answer is that count. For other bases and divisors, the scarce prime changes, and rule 2 below covers that.
The count of 5s is not simply n divided by 5. A number such as 25 contributes two 5s, and 125 contributes three. That is the reason for the full formula in the next section.
Rule 1: Divide by the Prime, Then by Its Powers
The number of times a prime p divides n factorial is the whole number part of n over p, plus the whole number part of n over p squared, plus the whole number part of n over p cubed, and so on until the terms become zero. Each term counts the numbers that have at least that power of p.
For 100 factorial and p equal to 5: 100 divided by 5 is 20, 100 divided by 25 is 4, and 100 divided by 125 is 0. The total is 24, so 100 factorial ends in 24 zeros. For 1000 factorial: 200 plus 40 plus 8 plus 1 equals 249 zeros.
The reason this works: the first term counts every multiple of 5 once, the second term counts a second time those that are multiples of 25, and so on. A multiple of 125 is counted three times, which matches the three 5s it holds. There is no need to list the numbers.
| n | n/5 | n/25 | n/125 | Trailing zeros of n factorial |
|---|---|---|---|---|
| 100 | 20 | 4 | 0 | 24 |
| 120 | 24 | 4 | 0 | 28 |
| 124 | 24 | 4 | 0 | 28 |
| 125 | 25 | 5 | 1 | 31 |
| 1000 | 200 | 40 | 8 (plus 1 from 625) | 249 |
Stopping at n divided by 5. For 100 factorial, that gives 20, and the correct answer is 24. Any question that includes a multiple of 25 needs the second term, and any with a multiple of 125 needs the third.
Rule 2: Composite Divisors Split Into Prime Powers
A question may ask for the highest power of 12 that divides 30 factorial, or the number of zeros of 50 factorial when written in base 12. First split the divisor into prime powers. Here, 12 is 2 squared times 3.
Count each prime in the factorial. In 30 factorial, the power of 2 is 15 plus 7 plus 3 plus 1, which is 26. The power of 3 is 10 plus 3 plus 1, which is 14. Now divide each count by the exponent in the divisor: 26 divided by 2 is 13, and 14 divided by 1 is 14. The highest power of 12 is the smaller of these, which is 13.
The same logic gives trailing zeros in other bases. A trailing zero in base 12 needs one factor of 12. For 50 factorial, the power of 2 is 25 plus 12 plus 6 plus 3 plus 1, which is 47, and the power of 3 is 16 plus 5 plus 1, which is 22. Divide 47 by 2 and take the whole part, 23. Compare with 22, and the smaller is 22. So 50 factorial ends in 22 zeros in base 12.
The Composite Divisor Routine
- Factorise the divisor into prime powers.
- Count each prime in n factorial using the divide-by-prime formula.
- Divide each count by the exponent of that prime in the divisor, keeping the whole part.
- Take the smallest result. That prime is the bottleneck.
Which Prime Is the Bottleneck
For 10, it is always 5, because 2s are more plentiful. For a divisor such as 15, which is 3 times 5, the bottleneck in n factorial is 5 again, because 5 is the larger prime and appears less often. For 50 factorial and base 15, the power of 3 is 22 and the power of 5 is 12, so the answer is 12 zeros.
A useful rule of thumb: when a divisor has a larger prime with the same exponent, the larger prime is usually the bottleneck. When the exponents differ, as in 12 or 72, calculate both and compare. Assuming the larger prime is the bottleneck can go wrong, so the habit is to compute and compare whenever the exponents are different.
For an exact check, take the smallest values of n and test. For a small case, you can list out the factorial. For a large one, trust the formula, and check one neighbouring value of n to confirm that the count behaves as you expect.
- Write the prime counts for 2, 3, 5 and 7 in a small column for the n you are given.
- Reuse them for every divisor in the same question.
- The counts for 5 are small, so they take seconds to compute.
Build Speed on Number System
Drill factorials, remainders, factors and bases in timed sets that match how CAT frames them.
Practice Number SystemRule 3: Reverse Problems and the Jump Trap
Some questions go backwards: find the smallest n whose factorial ends in a given number of zeros, or find how many values of n give a certain count. The trap is that the count of zeros does not rise by one each time. It jumps whenever n crosses a multiple of 25, 125 and higher powers of 5.
Look at the table above. The values of n from 120 to 124 all give 28 zeros. At n equal to 125, the count jumps to 31, because 125 brings three 5s at once. So 29 and 30 trailing zeros are impossible. No factorial ends in exactly 29 or exactly 30 zeros.
That gives two common question types. One asks whether a given zero count is possible, and the answer depends on whether the count lands in a jump. The other asks for how many values of n give a certain count, and the answer is 5 values for most counts, such as 120 to 124 for 28 zeros.
To solve a reverse problem, estimate n by multiplying the zero count by 4 and a little more, since each block of 5 adds one zero and each higher power adds a bit extra. Then test values near your estimate with the formula. For 28 zeros, an estimate of 120 gives exactly 28, and you confirm by testing 119, which gives 23 plus 4 equals 27. Since 119 gives one fewer, 120 is the smallest n.
Always test the boundaries. The smallest n for a zero count is always a multiple of 5, because the count can only rise when n reaches a new multiple of 5. That alone halves the number of values to test.
Other Questions in the Same Family
The same counting idea drives several related questions. The number of factors of n factorial is found from its prime factorisation, using the exponents you already computed, and the divisor count formula. The last non-zero digit of a factorial is a longer problem, and CAT rarely asks for large cases. The highest power of a prime that divides a product of consecutive numbers uses the same formula.
When a question mixes factorial with remainder, the usual route is to notice that for large n the factorial is divisible by the modulus, so the remainder is zero. For example, any factorial from 10 factorial onward is divisible by 100, so it leaves remainder zero on division by 100. Our guide on permutation and combination shortcuts shows how factorials appear in counting.
A last pattern to watch: a question may ask for the number of zeros at the end of a product, such as 20 factorial times 15 factorial, or of a ratio of factorials. Count the 5s in the whole product by adding the counts of the parts, or subtract for a ratio. Do not multiply the zero counts, because the counts of primes add, and the zero count is then read from the combined totals.
You can read more about how this chapter compares with others in our list of 20 Quant topics to cover before CAT 2026, and use the CAT cheatsheets page to keep the formula in one place.
Before you commit to a final answer on a reverse zero count problem, compute the count for n minus 1 and n. If they are equal, your n is not the smallest. If they differ, you have the right boundary. This takes seconds and avoids off by five errors.
Students often learn the divide by 5 formula and stop there. The ones who gain the most are those who also practise the composite divisor and the jump case, because those are the versions a question setter uses to separate memory from understanding.
- Can you find the zeros of 250 factorial in under a minute?
- Do you know which prime is the bottleneck for base 12?
- Can you explain why 29 zeros is impossible?
- Have you tested the smallest n rule on one example?
If you want to see how much time factorials deserve in your plan, you can talk to a CAT mentor about your Number System accuracy.
Plan Your Quant Revision
Build a plan around your weakest chapters, with practice slots for Number System.
Build My Study PlanFrequently Asked Questions About Factorials and Trailing Zeros
How many trailing zeros does 100 factorial have?
It has 24. Add 100 divided by 5, which is 20, and 100 divided by 25, which is 4, taking whole numbers each time.
How do you find the highest power of 12 in 30 factorial?
Split 12 into 2 squared times 3. The power of 2 in 30 factorial is 26 and of 3 is 14. Divide 26 by 2 to get 13, compare with 14, and take the smaller, 13.
Why can a factorial not end in exactly 30 zeros?
Because the zero count jumps from 28 at n equal to 124 to 31 at n equal to 125, when 125 brings three 5s at once. The values 29 and 30 are skipped.
Do I count 2s for trailing zeros in base 10?
No. The 2s are always more plentiful than the 5s in a factorial, so the number of 5s sets the count of trailing zeros.
Practice these Quant concepts, chapter by chapter
Thousands of CAT Quant practice questions by chapter and difficulty, each with a worked solution.
More from Quant
Continue reading

CMAT 2027: Notification Awaited, Expected Dates and Prep

MICAT 2027 Phase 1: Dates, Deadline and Who Can Apply

IIM Indore PGP 2027-29 Criteria: What Is Known So Far

IIM Calcutta 2027 Selection Criteria: Weights and Changes
Put it into practice