
|
100 factorial solution
I think the proposed solution ( http://www.techinterview.org/Solutions/fog0000000150.html ) is wrong.
Both factors of 10 and factors of 5 squared are also factors of 5.
So the only number that really matters is the number of factors of 5.
Which are 5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100.
For a total of 20 factors of 5, giving 20 trailing zeros.
Jonno
Sunday, March 14, 2004
whoops. when I said 'factor of 5' above, i meant 'multiple of 5'
Jonno
Sunday, March 14, 2004
I believe the numbers listed, namely these numbers,
5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100.
are indeed the numbers that "matters."
And indeed, we want to count how many factors of 5 we have in those numbers, but the total is not 20, the total is 24 as given in the "proposed solution."
Here is why
The following numbers have two factors of 5
25 = 5 * 5
50 = 2 * 5 * 5
75 = 3 * 5 * 5
100 = 4 * 5 * 5
so total = 20 + 4 = 24 factors of 5
JHY
Monday, March 15, 2004
24 is correct. To convince yourself, all you need to do is calculate 100! and count the zeros!
100! is
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
:-)
Paul Viney
Tuesday, March 16, 2004
or, using line breaks ...
93326215443944152681699238856266700
49071596826438162146859296389521759
99932299156089414639761565182862536
97920827223758251185210916864
000000000000000000000000
Paul Viney
Tuesday, March 16, 2004
Yep.
I am very wrong.
How embarrassment.
Jonno
Monday, March 22, 2004
Recent Topics
Fog Creek Home
|