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

 Prime time (Posted on 2010-10-08)
1. How many primes are in a clock if you regard the numbers on its face as a continuous clockwise string of digits; not to exceed 15 digits i.e. one full round?

2.Same question for a counterclockwise direction.

3.Same question for a digital watch ((HH(0-23)MM(0-59)) - in ascending order).
________________________________________

 No Solution Yet Submitted by Ady TZIDON No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution for parts 1 and 2 Comment 3 of 3 |

DECLARE SUB factor (num#, s\$)
DEFDBL A-Z
src\$ = "123456789101112123456789101112"

FOR l = 1 TO 15
FOR st = 1 TO 15
s\$ = MID\$(src\$, st, l)
n = VAL(s\$)
factor n, s1\$
IF LTRIM\$(s1\$) = s\$ THEN ct = ct + 1: PRINT ct, n
NEXT
NEXT l

ct = 0

src\$ = "211101987654321211101987654321"

FOR l = 1 TO 15
FOR st = 1 TO 15
s\$ = MID\$(src\$, st, l)
n = VAL(s\$)
factor n, s1\$
IF LTRIM\$(s1\$) = s\$ THEN ct = ct + 1: PRINT ct, n
NEXT
NEXT l

SUB factor (num, s\$)
s\$ = "": n = ABS(num): IF n > 0 THEN limit = SQR(n):  ELSE limit = 0
IF limit <> INT(limit) THEN limit = INT(limit + 1)
dv = 2: GOSUB DivideIt
dv = 3: GOSUB DivideIt
dv = 5: GOSUB DivideIt
dv = 7
DO UNTIL dv > limit
GOSUB DivideIt: dv = dv + 4 '11
GOSUB DivideIt: dv = dv + 2 '13
GOSUB DivideIt: dv = dv + 4 '17
GOSUB DivideIt: dv = dv + 2 '19
GOSUB DivideIt: dv = dv + 4 '23
GOSUB DivideIt: dv = dv + 6 '29
GOSUB DivideIt: dv = dv + 2 '31
GOSUB DivideIt: dv = dv + 6 '37
IF INKEY\$ = CHR\$(27) THEN s\$ = CHR\$(27): EXIT SUB
LOOP
IF n > 1 THEN s\$ = s\$ + STR\$(n)
EXIT SUB

DivideIt:
DO
q = INT(n / dv)
IF q * dv = n AND n > 0 THEN
n = q: s\$ = s\$ + STR\$(dv): IF n > 0 THEN limit = SQR(n):  ELSE limit = 0
IF limit <> INT(limit) THEN limit = INT(limit + 1)
ELSE
EXIT DO
END IF
LOOP
RETURN
END SUB

first finds the primes in the forward direction of the digits:

`1             22             33             54             75             26             237             678             899             1110            1111            10112            456713            6789114            8910115            1011116            78910117            456789118            2345678919            5678910120            123456789121            4567891011122            12345678910111`

While the above counts 22 primes, the prime 2 appears twice (once from the solitary 2 on the clock face and once from the 12), and the prime 11 appears twice (once from 11 itself and once from the end of 11 and the beginning of 12), so only 20 distinct primes actually appear.

The same holds in the reverse clockface:

` 1             2 2             7 3             5 4             3 5             2 6             11 7             11 8             19 9             43 10            211 11            101 12            2111 13            1019 14            1987 15            76543 16            21211 17            101987 18            432121 19            4321211 20            12111019 21            6543212111 22            9876543212111 `

Two and eleven appear here also twice each, so the 22 occurrences are just 20 distinct primes.

The forward direction had no examples of wrapping around the top of the clockface, but the reverse does, with 32121 appearing in four of the primes and 2121 in another.

 Posted by Charlie on 2010-10-08 15:34:46

 Search: Search body:
Forums (0)