2022-03-09
[public] 39.9K views, 40.0K likes, dislikes audio only
You can determine the number of trailing zeroes on a factorial of ANY size with a pretty simple trick that involves dividing by powers of 5. First, you can do it the hard way, and multiple every number of x! (x * (x - 1) * (x - 2)...) until you're multiplying by 1 at the end, and then just count up the zeroes. Or... you can do it the smart way.
Divide your original number by 5, then 5^2, then 5^3, and when you've got a fractional value, stop and add up the rounded-down whole numbers. And BAM! That's how many trailing zeroes x! has. It really is that easy, even for a 206-digit number like 123!
#shorts