Carmichael 3 strong pseudoprimes: Difference between revisions
Content added Content deleted
(→{{header|Nim}}: Correct loop limits) |
(Carmichael 3 strong pseudoprimes en BASIC256) |
||
Line 341: | Line 341: | ||
69 numbers |
69 numbers |
||
</pre> |
</pre> |
||
=={{header|BASIC256}}== |
|||
{{trans|FreeBASIC}} |
|||
<lang BASIC256> |
|||
for i = 3 to max_sieve step 2 |
|||
isprime[i] = 1 |
|||
next i |
|||
isprime[2] = 1 |
|||
for i = 3 to sqr(max_sieve) step 2 |
|||
if isprime[i] = 1 then |
|||
for j = i * i to max_sieve step i * 2 |
|||
isprime[j] = 0 |
|||
next j |
|||
end if |
|||
next i |
|||
subroutine carmichael3(p1) |
|||
if isprime[p1] <> 0 then |
|||
for h3 = 1 to p1 -1 |
|||
t1 = (h3 + p1) * (p1 -1) |
|||
t2 = (-p1 * p1) % h3 |
|||
if t2 < 0 then t2 = t2 + h3 |
|||
for d = 1 to h3 + p1 -1 |
|||
if t1 % d = 0 and t2 = (d % h3) then |
|||
p2 = 1 + (t1 \ d) |
|||
if isprime[p2] = 0 then continue for |
|||
p3 = 1 + (p1 * p2 \ h3) |
|||
if isprime[p3] = 0 or ((p2 * p3) % (p1 -1)) <> 1 then continue for |
|||
print p1; " * "; p2; " * "; p3 |
|||
end if |
|||
next d |
|||
next h3 |
|||
end if |
|||
end subroutine |
|||
for i = 2 to 61 |
|||
call carmichael3(i) |
|||
next i |
|||
end |
|||
</lang> |
|||
=={{header|C}}== |
=={{header|C}}== |