Counting number of occurrences of a number in a factorial

608 Views Asked by At

Consider that I want to count the number of times 360 occurs in 520!

$360 = 2^3 \cdot 3^2 \cdot 5^1$

$520! = 1\cdot2\cdot3\cdot4\cdot\cdots$

As it can be noticed, $2$ occurs at least $3$ times before $5.$ As for $3^2,$ it is doubtful as to how many times it occurs before $5.$ So I checked for both $3^2$ and $5.$ $5$ occurs $128$ times in $520!$ and $3^2$ occurs $128$ times as well. On the other hand, $2^3$ appears $172$ times. So it can be safely said that $360$ occurs $128$ times in $520!$

My question is since it is obvious that $2$ appears at least thrice before $5,$ could the calculation of the number of occurrences for $2^3$ be ignored? Can this be done in all scenarios? If not, what can be some exceptions?