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

Home > Numbers
Circular Prime Puzzle (Posted on 2024-11-05) Difficulty: 3 of 5
A circular prime is one in which all cyclic permutations of its digits are prime. For example, 1193 is a circular prime because 1931, 9311, and 3119 are prime.

Find the largest circular prime less than 1,000,000.

No Solution Yet Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Computer solution | Comment 1 of 2
The answer is 999331 which is, in fact, the largest known circular prime which is not a repunit.
(1111111111111111111 for example is a circular prime)

999331
993319
939391
939193
933199
919393
393919
391939
331999
319993
199933
193939
99371
93911
93719
91193
71993
39119
37199
19937
19391
11939
9377
9311
7937
7793
3779
3119
1931
1193
991
971
919
733
719
373
337
311
199
197
131
113
97
79
73
71
37
31
17
13
11
7
5
3
2
(my algorithm skipped any number with an even digit so I manually added the final entry: 2)

-----------------
for n in range(999999,1,-2):
    strn = str(n)
    fail = False
    for digit in '02468':
        if digit in strn:
            fail = True
    if fail:
        continue
    number_digits = len(strn)
    eabcd = strn
    for ind in range(number_digits):
        if not isprime(int(eabcd)):
            fail = True
            break
        eabcd = eabcd[-1] + eabcd[:-1]
    if fail:
        continue
    print(n)
    

  Posted by Larry on 2024-11-05 11:23:12
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 (5)
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