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

Home > Just Math
Curious Consecutive Cyphers II (Posted on 2009-02-23) Difficulty: 2 of 5
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?

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution 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 zeros
3             0             0
4             0             0
5             1             0
6             1             0
7             1             0
8             1             0
9             1             0
10            2             0
11            2             0
12            2             0
13            2             0
14            2             0
15            3             0
16            3             0
17            3             0
18            3             0
19            3             0
20            4             0
21            4             0
22            4             0
23            4             0
24            4             0
25            6             1
26            6             1
27            6             1
28            6             1
29            6             1
30            7             1
31            7             1
32            7             1
33            7             1
34            7             1
35            8             1
36            8             1
37            8             1
38            8             1
39            8             1
40            9             1
41            9             1
42            9             1
43            9             1
44            9             1
45            10            1
46            10            1
47            10            1
48            10            1
49            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

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information