Jump to content

Carmichael 3 strong pseudoprimes: Difference between revisions

Line 2,884:
61 x 241 x 421 = 6189121
61 x 3361 x 4021 = 824389441
</pre>
 
=={{header|Vala}}==
{{trans|D}}
<lang vala>long mod(long n, long m) {
return ((n % m) + m) % m;
}
 
bool is_prime(long n) {
if (n == 2 || n == 3)
return true;
else if (n < 2 || n % 2 == 0 || n % 3 == 0)
return false;
for (long div = 5, inc = 2; div * div <= n;
div += inc, inc = 6 - inc)
if (n % div == 0)
return false;
return true;
}
 
void main() {
for (long p = 2; p <= 63; p++) {
if (!is_prime(p)) continue;
for (long h3 = 2; h3 <= p; h3++) {
var g = h3 + p;
for (long d = 1; d <= g; d++) {
if ((g * (p - 1)) % d != 0 || mod(-p * p, h3) != d % h3)
continue;
var q = 1 + (p - 1) * g / d;
if (!is_prime(q)) continue;
var r = 1 + (p * q / h3);
if (!is_prime(r) || (q * r) % (p - 1) != 1) continue;
stdout.printf("%5ld × %5ld × %5ld = %10ld\n", p, q, r, p * q * r);
}
}
}
}</lang>
{{out}}
<pre>
3 × 11 × 17 = 561
3 × 3 × 5 = 45
5 × 29 × 73 = 10585
5 × 5 × 13 = 325
5 × 17 × 29 = 2465
5 × 13 × 17 = 1105
7 × 19 × 67 = 8911
7 × 31 × 73 = 15841
7 × 13 × 31 = 2821
7 × 23 × 41 = 6601
7 × 7 × 13 = 637
7 × 73 × 103 = 52633
7 × 13 × 19 = 1729
11 × 11 × 61 = 7381
11 × 11 × 41 = 4961
11 × 11 × 31 = 3751
13 × 61 × 397 = 314821
13 × 37 × 241 = 115921
13 × 97 × 421 = 530881
13 × 37 × 97 = 46657
13 × 37 × 61 = 29341
17 × 41 × 233 = 162401
17 × 17 × 97 = 28033
17 × 353 × 1201 = 7207201
19 × 43 × 409 = 334153
19 × 19 × 181 = 65341
19 × 19 × 73 = 26353
19 × 19 × 37 = 13357
19 × 199 × 271 = 1024651
23 × 23 × 89 = 47081
23 × 23 × 67 = 35443
23 × 199 × 353 = 1615681
29 × 29 × 421 = 354061
29 × 113 × 1093 = 3581761
29 × 29 × 281 = 236321
29 × 197 × 953 = 5444489
31 × 991 × 15361 = 471905281
31 × 61 × 631 = 1193221
31 × 151 × 1171 = 5481451
31 × 31 × 241 = 231601
31 × 61 × 271 = 512461
31 × 61 × 211 = 399001
31 × 271 × 601 = 5049001
31 × 31 × 61 = 58621
31 × 181 × 331 = 1857241
37 × 109 × 2017 = 8134561
37 × 73 × 541 = 1461241
37 × 613 × 1621 = 36765901
37 × 73 × 181 = 488881
37 × 37 × 73 = 99937
37 × 73 × 109 = 294409
41 × 1721 × 35281 = 2489462641
41 × 881 × 12041 = 434932961
41 × 41 × 281 = 472361
41 × 41 × 241 = 405121
41 × 101 × 461 = 1909001
41 × 241 × 761 = 7519441
41 × 241 × 521 = 5148001
41 × 73 × 137 = 410041
41 × 61 × 101 = 252601
43 × 631 × 13567 = 368113411
43 × 271 × 5827 = 67902031
43 × 127 × 2731 = 14913991
43 × 43 × 463 = 856087
43 × 127 × 1093 = 5968873
43 × 211 × 757 = 6868261
43 × 631 × 1597 = 43331401
43 × 127 × 211 = 1152271
43 × 211 × 337 = 3057601
43 × 433 × 643 = 11972017
43 × 547 × 673 = 15829633
43 × 3361 × 3907 = 564651361
47 × 47 × 277 = 611893
47 × 47 × 139 = 307051
47 × 3359 × 6073 = 958762729
47 × 1151 × 1933 = 104569501
47 × 3727 × 5153 = 902645857
53 × 53 × 937 = 2632033
53 × 157 × 2081 = 17316001
53 × 79 × 599 = 2508013
53 × 53 × 313 = 879217
53 × 157 × 521 = 4335241
53 × 53 × 157 = 441013
59 × 59 × 1741 = 6060421
59 × 59 × 349 = 1214869
59 × 59 × 233 = 811073
59 × 1451 × 2089 = 178837201
61 × 421 × 12841 = 329769721
61 × 181 × 5521 = 60957361
61 × 61 × 1861 = 6924781
61 × 1301 × 19841 = 1574601601
61 × 277 × 2113 = 35703361
61 × 181 × 1381 = 15247621
61 × 541 × 3001 = 99036001
61 × 661 × 2521 = 101649241
61 × 271 × 571 = 9439201
61 × 241 × 421 = 6189121
61 × 3361 × 4021 = 824389441
</pre>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.