Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I was just trying to work out the exponent for $7$ in the number $343!$. I think the right technique is $$\frac{343}{7}+\frac{343}{7^2}+\frac{343}{7^3}=57.$$ If this is right, can the technique be generalized to $p$ a prime number, $n$ any positive integer, then the exponent of $p$ in $n!$ will be $$\sum_{k=1}^\infty\left\lfloor\frac{n}{p^k}\right\rfloor\quad ?$$ Here, $\lfloor\cdot\rfloor$ denotes the integer less than or equal to $\cdot$ .

Obviously the sum is finite, but I didn't know if it was correct (since its veracity depends on my first solution anyway).

share|improve this question
Yes. Now use this to find the number of trailing zeros :) –  M.B. Oct 14 '13 at 17:55
@M.B.: Would I use $p=2$ and $p=5$ in such an instance, then take whichever one is smaller? Also, should I delete the question now? Or should you just write "Yes." as an answer? –  anon271828 Oct 14 '13 at 17:56
Yup, I guess you mean the larger of the two? Clearly there are more twos than fives. You should probably give this question a closure, e.g. by replying to it yourself. –  M.B. Oct 14 '13 at 17:58
@M.B.: What do you mean by the larger of the two? To count the number of trailing zeros, I need to pair off a $2$ with a $5$. Since I believe your statement about there being more $2$'s than $5$'s is true regardless of the integer $n$, I really only need to count the exponent on $5$, right? This will give me the number of trailing zeros? Thanks. –  anon271828 Oct 14 '13 at 18:01
You're right that you count the $5$'s rather than the $2$'s. I guess that either M.B. was just wrong, or they meant that you should take the larger in the sense that $5>2$. A fun way to get an approximate answer is to forget the $\lfloor\rfloor$ signs and then sum the geometric series. So for instance $n!$ has about $n/4$ trailing zeros. –  Oscar Cunningham Oct 14 '13 at 18:09

1 Answer 1

Both the solution and its generalization are correct, as @M.B. points out in the comments to the original post. As a corollary, this provides an easy way to count the number of trailing zeros.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.