Trailing Zeros in Factorials

<p><a href="https://www.prepswift.com/quizzes/quiz/prepswift-trailing-zeros-in-factorials" target="_blank">Trailing Zeros in Factorials Exercise</a></p><p><strong><span style="color:#e74c3c;"><span style="font-size:18px;">What are Trailing Zeros?</span></span></strong></p> <p>Trailing zeros are the consecutive $0$s at the end of an integer. For example, $10$ has one trailing zero, $100$ has two, and $1$,$000$,$000$ has $6$.</p> <p>Notice the following pattern:</p> <p>$$10^1=10$$</p> <p>$$10^2=100$$</p> <p>$$10^3=1,000$$</p> <p>$$10^4=10,000$$</p> <p>The number of trailing zeros depends entirely on the number of powers of $10$ in our integer. If we have one power of $10$, we have one trailing zero. If we have eight powers of $10$, we have $8$ trailing zeros.&nbsp;</p> <p><strong><span style="font-size:18px;"><span style="color:#e74c3c;">Let&#39;s Look at an Example</span></span></strong></p> <p>How many trailing zeros are there in $270!$? In other words, how many powers of $10$ are there in $270!$?</p> <p>$$\frac{270!}{10^x}$$</p> <p>To apply our &quot;trick,&quot; we have to break $10$ down into the primes $2 \times 5$, and we know that $5$s are less common than $2$s, so $5$s are our limiting factor. So rewrite the problem as and then apply our trick (learned previously)...</p> <p>$$\frac{270!}{5^x}$$</p> <p style="text-align: center;"><span style="color:#e74c3c;"><em>Continuously divide by $5$ and take the whole number result&nbsp;</em></span></p> <p>$$54...10...2...0 = 66$$</p> <p>So $270!$ has $66$ zeros at the end. You can see the <a href="https://gregmatapi.s3.amazonaws.com/media/misc/files/270_factorial_trailing_zeros.PNG">number here</a> in all its glory if you&#39;d like to confirm.</p>