Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Circular Primes as done at Software Tools For Mathematics Koper 2018

Views: 139
Kernel: SageMath (stable)

Circular Primes

p = 19937 p.is_prime()
True
print(19937.is_prime()) print(71993.is_prime()) print(37199.is_prime()) print(93719.is_prime()) print(99371.is_prime())
True True True True True
print(Primes()) print(Primes()[:100])
Set of all prime numbers: 2, 3, 5, 7, ... [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541]
def rotate(s): return s[1:] + s[0] def is_circular(p): pstring = str(p) for i in range(len(pstring)): pstring = rotate(pstring) q = ZZ(pstring, base=10) if not q.is_prime(): return False return True for p in Primes()[:100000]: if is_circular(p): print(p)
2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 7937 9311 9377 11939 19391 19937 37199 39119 71993 91193 93719 93911 99371 193939 199933 319993 331999 391939 393919 919393 933199 939193 939391 993319 999331