Jump to content

Carmichael 3 strong pseudoprimes: Difference between revisions

(→‎{{header|REXX}}: added a version that shows the Carmichael numbers in sorted order. -- ~~~~)
Line 253:
if (p2 * p3) % (p1 - 1) == 1:
#print('%i X %i X %i' % (p1, p2, p3))
ans += [tuple(sorted((p1, p2, p3)))]
return ans
isprime = Isprime(2)
ans = sorted(sum((carmichael(n) for n in range(62) if isprime(n)), []))
print(',\n'.join(repr(ans[i:i+5])[1:-1] for i in range(0, len(ans)+1, 5)))</lang>
{{out}}
<pre>(3, 11, 17), (5, 2913, 7317), (5, 17, 29), (5, 1329, 1773), (7, 1913, 6719),
(7, 3113, 7331), (7, 1319, 3167), (7, 23, 41), (7, 7331, 10373), (7, 1373, 19103),
(13, 6137, 39761), (13, 37, 24197), (13, 9737, 421241), (13, 3761, 97397), (13, 3797, 61421),
(17, 41, 233), (17, 353, 1201), (19, 43, 409), (19, 199, 271), (23, 199, 353),
(29, 113, 1093), (29, 197, 953), (31, 99161, 15361211), (31, 61, 631271), (31, 15161, 1171631),
(31, 61151, 2711171), (31, 61181, 211331), (31, 271, 601), (31, 181991, 33115361), (37, 10973, 2017109),
(37, 73, 541181), (37, 61373, 1621541), (37, 73109, 1812017), (37, 73613, 1091621), (41, 172161, 35281101),
(41, 88173, 12041137), (41, 101, 461), (41, 241, 761521), (41, 241, 521761), (41, 73881, 13712041),
(41, 611721, 10135281), (43, 631127, 13567211), (43, 271127, 58271093), (43, 127, 2731), (43, 127211, 1093337),
(43, 211, 757), (43, 631271, 15975827), (43, 127433, 211643), (43, 211547, 337673), (43, 433631, 6431597),
(43, 547631, 67313567), (43, 3361, 3907), (47, 33591151, 60731933), (47, 11513359, 19336073), (47, 3727, 5153),
(53, 15779, 2081599), (53, 79157, 599521), (53, 157, 5212081), (59, 1451, 2089), (61, 421181, 128411381),
(61, 181, 5521), (61, 1301241, 19841421), (61, 277271, 2113571), (61, 181277, 13812113), (61, 541421, 300112841),
(61, 661541, 25213001), (61, 271661, 5712521), (61, 2411301, 42119841), (61, 3361, 4021)</pre>
 
=={{header|REXX}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.