Jump to content

Carmichael 3 strong pseudoprimes: Difference between revisions

Added 11l
m (→‎{{header|REXX}}: added/changed comments and whitespace, optimized a DO loop.)
(Added 11l)
Line 30:
<tt>Prime<sub>1</sub> * Prime<sub>2</sub> * Prime<sub>3</sub> is a Carmichael Number</tt>
<br><br>
 
=={{header|11l}}==
{{trans|D}}
<lang 11l>F mod_(n, m)
R ((n % m) + m) % m
F is_prime(n)
I n C (2, 3)
R 1B
E I n < 2 | n % 2 == 0 | n % 3 == 0
R 0B
V div = 5
V inc = 2
L div ^ 2 <= n
I n % div == 0
R 0B
div += inc
inc = 6 - inc
R 1B
L(p) 2 .< 62
I !is_prime(p)
L.continue
L(h3) 2 .< p
V g = h3 + p
L(d) 1 .< g
I (g * (p - 1)) % d != 0 | mod_(-p * p, h3) != d % h3
L.continue;
V q = 1 + (p - 1) * g I/ d;
I !is_prime(q)
L.continue
V r = 1 + (p * q I/ h3)
I !is_prime(r) | (q * r) % (p - 1) != 1
L.continue
print(p‘ x ’q‘ x ’r)</lang>
{{out}}
<pre>
3 x 11 x 17
5 x 29 x 73
5 x 17 x 29
5 x 13 x 17
7 x 19 x 67
7 x 31 x 73
7 x 13 x 31
7 x 23 x 41
...
61 x 1301 x 19841
61 x 277 x 2113
61 x 181 x 1381
61 x 541 x 3001
61 x 661 x 2521
61 x 271 x 571
61 x 241 x 421
61 x 3361 x 4021
</pre>
 
=={{header|Ada}}==
1,481

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.