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

Home > Numbers
Prime time (Posted on 2010-10-08) Difficulty: 4 of 5
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.)
Some Thoughts 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             2
2             3
3             5
4             7
5             2
6             23
7             67
8             89
9             11
10            11
11            101
12            4567
13            67891
14            89101
15            10111
16            789101
17            4567891
18            23456789
19            56789101
20            1234567891
21            45678910111
22            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
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 (7)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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