Factorial Zeroes

Puzzle I came up with last night, no calculators allowed:

The Puzzle

The final 12 digits of N! (N Factorial) are all zeroes. What is the smallest number N can be?

Further

Generalising this, i.e. finding a formula for the smallest factorial ending in M zeroes, is really quite a pain to do. I’ve not managed it. It would be very easy to write an algorithm for finding solutions, but that’s less fun and not in the non-calculator spirit.

The simpler problem of finding the number of trailing zeroes of any given factorial is made trivial by the formula given in the hints below.

The Solution

SPOILERs!

Hint 1

N! must be a multiple of 10^12

Hint 2

Prime factors of 10 are 5 and 2.

Hint 3

Multiples of 2 always outnumber multiples of 5. Therefore, you only need to keep track of multiples of 5.

Hint 4

Remember that some multiples of 5 have more than one 5 in their prime factors.

Hint 5

There’s even a formula! (You shouldn’t need to use this but it’s here)

Answer

The solution is N=50

Next:
Haskelldump
Previous:
Prime Riddle
Tags:
Geeking · Puzzles