Carmichael 3 strong pseudoprimes: Difference between revisions

Content added Content deleted
(First implementation in PL/I)
(GP)
Line 279: Line 279:
p2, 1 + Floor[p1 p2/h3]}], {p1_, p2_, p3_} /;
p2, 1 + Floor[p1 p2/h3]}], {p1_, p2_, p3_} /;
Mod[p2 p3, p1 - 1] == 1 :> Print[p1, "*", p2, "*", p3]]</lang>
Mod[p2 p3, p1 - 1] == 1 :> Print[p1, "*", p2, "*", p3]]</lang>
=={{header|PARI/GP}}==
<lang parigp>f(p)=my(v=List(),q,r);for(h=2,p-1,for(d=1,h+p-1,if((h+p)*(p-1)%d==0&&Mod(-p,h)^2==d,if(isprime(q=(p-1)*(h+p)/d+1)&&isprime(r=p*q\h+1)&&q*r%(p-1)!=1,listput(v,p*q*r)))));Set(v)
forprime(p=3,67,v=f(p); for(i=1,#v,print1(v[i]", ")))</lang>
{{out}}
<pre>8695, 540793, 552563, 21607, 5814901, 8209657, 500867, 2158003, 6301153, 1480111, 30832211, 1363178701, 3729863, 636757889, 1061464331, 2546740153, 11674241, 4396516867, 673819, 7113859, 22226111, 43370641, 74183807,</pre>

=={{header|Perl 6}}==
=={{header|Perl 6}}==
An almost direct translation of the pseudocode. We take the liberty of going up to 67 to show we aren't limited to 32-bit integers. (Perl 6 uses arbitrary precision in any case.)
An almost direct translation of the pseudocode. We take the liberty of going up to 67 to show we aren't limited to 32-bit integers. (Perl 6 uses arbitrary precision in any case.)