### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,367)
- misc (4)
- project euler (2)
- puzzle (90)
- puzzle# (48)
- site news (58)
- tantalizer (94)
- teaser (7)

### Site Stats

- 233,130 hits

Programming Enigma Puzzles

16 November 2015

Posted by on **From New Scientist #2349, 29th June 2002** [link]

George has been explaining to his young son the concept of factorials, which are denoted by an exclamation mark. The factorial of three, denoted 3!, is 1 × 2 × 3 = 6. The factorial of 10 (10!) is 1 × 2 × 3 × 4 × 5 × 6 × 7 × 8 × 9 × 10 = 3,628,800.

“In that case, Dad, the factorial of one million (1,000,000!) must be a very large number.”

“Indeed so — it has more than five million digits, ending with a long string of zeros.”

How many zeros?

This **Enigma** appeared in the styling that was used for the remainder of **Enigma** puzzles, up to December 2013.

[enigma1193]

%d bloggers like this:

The number of zeros depends on the number of times 5 appears as a factor (as there are always enough 2 factors to multiply it up to 10).

This Python program counts the number of factors that are various powers of 5.

For 1000000! it calculates the result in 31ms.

Solution:The decimal representation of 1,000,000! ends in 249,998 zeros.A manual solution:

The above analysis leads to a one line Python solution :