What is the smallest value of X , such that X ! has 1000 trailing zeros ?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
i = 1 ∑ ⌊ 5 i x ⌋ = 1 0 0 0 ∴ 4 x ≈ 1 0 0 0 ⇒ x ≈ 4 0 0 0
but i = 1 ∑ ⌊ 5 i 4 0 0 0 ⌋ = 8 0 0 + 1 6 0 + 3 2 + 6 + 1 = 9 9 9
So should add one 5 more, i.e. x = 4 0 0 5
I used the Legendre equation. If 1000 traling zeros are needed then ⌊ 5 X ⌋ + ⌊ 5 2 X ⌋ + ⌊ 5 3 X ⌋ + ⌊ 5 4 X ⌋ + ⌊ 5 5 X ⌋ = 1 0 0 0
X = 7 8 1 1 0 0 0 ⋅ 3 1 2 5 ≅ 4 0 0 1
It's near the result because the next 5 multiple 4005 is the correct answer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Close. Instead of outputting just the lowest number with 1000 trailing zeros, it outputs all numbers with exactly that many trailing zeros (4005..4009 in this case). If I had picked a number like 5 instead of 1000, your solution wouldn't output anything because 24! has 4 trailing zeros while 25! has 6 trailing zeros. Also, you can speed the program up quite a bit without adding much complexity by calculating the factorial as you loop. I would use something like this for your last block of code:
1 2 3 4 5 6 7 |
|
Problem Loading...
Note Loading...
Set Loading...
This problem was inspired by one of the daily problems .
From the previous problem, we observe that the number of trailing zeros approaches n/4, so a good starting point would be 4000 (although we would expect that to be slightly under 1000).
4000! has 800 multiples of 5; 160 multiples of 25; 32 multiples of 125; 6 multiples of 625; and 3125. As suspected, that's 999 trailing zeros.
4001, 4002, 4003, and 4004 don't add any more 5s.
4005! has 801 multiples of 5; 160 multiples of 25; 32 multiples of 125; 6 multiples of 625; and 3125. That's exactly 1000 trailing zeros.