Mathematics Problem Of the Week

Fall 2006

POW #9

Factorial Storage

 

Trish Compact has been asked by her boss to compute factorials of very large numbers, but she is worried about space limitations on her hard disk drive. She has decided that, instead of storing the entire factorial value, she will only store the leftmost digits of the factorial up to (and including) the rightmost nonzero digit, and then just store a count of the number of rightmost zero digits. 

 

[Recall that n factorial (n!) is equal to the product of all the integers from 1 to n. For example, 6! = 1·2·3·4·5·6 = 720 and 10! = 3628800. So Trish’s computer representation of 6! has 1 rightmost zero digit, and 10! has 2 rightmost zero digits.]

 

Trish needs to figure out a way to calculate the number of rightmost zeroes in the decimal representation of n!, given n.  Help Trish by constructing a function f in terms of n to do this.

 

Here are some example inputs and outputs of f to help you check. 

f(4) = 0               (since 4!=24, so no rightmost zeros)

f(17) = 3             (since 17!= 355687428096000)

f(626) = 156

f(74972975) = 18743238   

 

Also, find f(2006).

Due Friday, November 17th at Noon.

Solutions should be submitted to Dr. R. Lock's mailbox in the Math office or sent via e-mail to rlock@stlawu.edu.