All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Curious Consecutive Cyphers II (Posted on 2009-02-23)
A positive integer T is defined as a factorial tail if there exists a positive integer P such that the decimal expansion of P! ends with precisely T consecutive zeroes, and (T+1)th digit from the right in P! is nonzero.

How many positive integers less than 1992 are not factorial tails?

 No Solution Yet Submitted by K Sengupta No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution | Comment 2 of 7 |

I get 396, as follows:

The first factorial ending in a zero is 5!, which ends in one zero. As multiples of 5 are less frequent than multiples of 2, each multiple of 5 adds at least one to the current number of terminal zeros as the factorials get larger. Multiples of 25 add two terminal zeros, and those of 125 add three, etc.

The following program, therefore, counts the multiples of 5 and multiples of the powers of 5 in any given number to arrive at the number of zeros in its factorial.  When that number goes up by more than one at a given point, then the excess over 1 is counted as having been skipped:

DEFDBL A-Z

DO
i = i + 1
n = i
dvsr = 5
zeros = 0
DO
zeros = zeros + n \ dvsr
dvsr = dvsr * 5
LOOP UNTIL n dvsr = 0
IF zeros > prevZeros + 1 THEN
ct = ct + zeros - prevZeros - 1
END IF
IF i < 50 THEN PRINT n, zeros, ct
prevZeros = zeros
LOOP UNTIL zeros >= 1992
PRINT n, zeros, ct

`n        number of zeros  count of          in factorial   skipped numbers of zeros3             0             04             0             05             1             06             1             07             1             08             1             09             1             010            2             011            2             012            2             013            2             014            2             015            3             016            3             017            3             018            3             019            3             020            4             021            4             022            4             023            4             024            4             025            6             126            6             127            6             128            6             129            6             130            7             131            7             132            7             133            7             134            7             135            8             136            8             137            8             138            8             139            8             140            9             141            9             142            9             143            9             144            9             145            10            146            10            147            10            148            10            149            10            1`
`. . .`
`7980          1992          396`

The number 7980 is the first to have 1992 terminal zeros in its factorial, by which time 396 possible number of zeros were skipped over.

Attempt at analytic solution:

1992 * 5 = 9960, so if only multiples of 5 added 1 to the number of zeros, it would be 9960 that would get to that number of zeros.

However 9960 / 25 is 398+, so take 398*5=1990 off and it's only 7970 that you need to go up to. But 7970/25 is only 318+, so we took too many off.

It seems we'd have to go through several stages of balancing for each power of 5 until we got it right. Perhaps there's a more direct way.

Edited on February 23, 2009, 12:55 pm
 Posted by Charlie on 2009-02-23 12:27:29

 Search: Search body:
Forums (1)