Carmichael 3 strong pseudoprimes: Difference between revisions
Content added Content deleted
(Updated D entry) |
No edit summary |
||
Line 277: | Line 277: | ||
(61,241,421) |
(61,241,421) |
||
(61,3361,4021) |
(61,3361,4021) |
||
</pre> |
|||
=={{header|Icon}} and {{header|Unicon}}== |
|||
The following works in both languages. |
|||
<lang unicon>link "factors" |
|||
procedure main(A) |
|||
n := integer(!A) | 61 |
|||
every write(carmichael3(!n)) |
|||
end |
|||
procedure carmichael3(p1) |
|||
every (isprime(p1), (h := 1+!(p1-1)), (d := !(h+p1-1))) do |
|||
if (mod(((h+p1)*(p1-1)),d) = 0, mod((-p1*p1),h) = mod(d,h)) then { |
|||
p2 := 1 + (p1-1)*(h+p1)/d |
|||
p3 := 1 + p1*p2/h |
|||
if (isprime(p2), isprime(p3), mod((p2*p3),(p1-1)) = 1) then |
|||
suspend format(p1,p2,p3) |
|||
} |
|||
end |
|||
procedure mod(n,d) |
|||
return (d+n%d)%d |
|||
end |
|||
procedure format(p1,p2,p3) |
|||
return left(p1||" * "||p2||" * "||p3,20)||" = "||(p1*p2*p3) |
|||
end</lang> |
|||
Output, with middle lines elided: |
|||
<pre> |
|||
->c3sp |
|||
3 * 11 * 17 = 561 |
|||
5 * 29 * 73 = 10585 |
|||
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 * 73 * 103 = 52633 |
|||
7 * 13 * 19 = 1729 |
|||
13 * 61 * 397 = 314821 |
|||
13 * 37 * 241 = 115921 |
|||
... |
|||
53 * 157 * 2081 = 17316001 |
|||
53 * 79 * 599 = 2508013 |
|||
53 * 157 * 521 = 4335241 |
|||
59 * 1451 * 2089 = 178837201 |
|||
61 * 421 * 12841 = 329769721 |
|||
61 * 181 * 5521 = 60957361 |
|||
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> |
</pre> |
||