Wednesday, November 16, 2011

Factorials, revisited from yesterday

I spent yesterday evening playing with factorial values because it was unclear to me why there would be 374 trailing zeros in 1500!. It was evident, even trivial, when I thought about it - I just never had before. All non-trivial factorials end in a string of 0s. I guess in school we never played with such big examples so it wasn't obvious that 0s were piling up at the end. (My school was before calculators or computers - we did all our arithmetic by hand. 1500! would have been extremely onerous and error-prone!)

So then I tried to figure out how to compute the number of trailing zeros - I got close, but missed the leap. Turns out that you just keep dividing the original number by 5 and summing the truncated results. Very cool. So for my 1500 book example:

       1500 / 5 = 300
         300 / 5 =  60
           60 / 5 =  12
           12 / 5 =    2
                     = 374
                        QED!

Numbers are so stinkin' cool to play around with! I should do it more often - one of the few things I left behind of my kidhood. It's nice when something shows up and throws me back into it. Numbers rock!

*     *     *     *     *     *

No comments:

Post a Comment