Anonymous user
Carmichael 3 strong pseudoprimes: Difference between revisions
m
→{{header|Julia}}
Line 1,303:
'''Function'''
<lang
function carmichael
car = Vector{typeof(pmax)}(0)
for p in primes(pmax)
for h₃ in 2:(p-1)
m = (p - 1) * (h₃ + p)
pmh = mod(-p ^ 2, h₃)
for Δ in 1:(h₃+p-1)
if m % Δ !=
q =
if !isprime(q)
r =
if !isprime(r)
append!(car, [p, q, r])
end
end
end
return reshape(car, 3,
end</lang>
'''Main'''
<lang
car = carmichael(hi)
curp = tcnt = 0
for j in sortperm(1:size(car)[2], by=x->(car[1,x], car[2,x], car[3,x]))
p, q, r = car[:, j]
c = prod(car[:, j])
if p != curp
curp = p
tcnt = 0
end
Line 1,347 ⟶ 1,345:
tcnt += 1
end
end
println("\n\n", size(car)[2], " results in total.")</lang>
{{out}}
<pre>Carmichael 3 (p×q×r) pseudoprimes, up to p = 61:
▲Carmichael 3 (p×q×r) Pseudoprimes, up to p = 61:
p =
p = 17
p = 19
p× 59 × 113 = 126673 p× 139 × 661 = 1745701 p× 193 × 283 = 1037761
p = 23
p× 43 × 53 = 52417 p× 59 × 227 = 308039 p× 71 × 137 = 223721 p× 83 × 107 = 204263
p = 29
p× 41 × 109 = 129601 p× 89 × 173 = 446513 p× 97 × 149 = 419137 p× 149 × 541 = 2337661
p = 31
p× 67 × 1039 = 2158003 p× 73 × 79 = 178777 p× 79 × 307 = 751843 p× 223 × 1153 = 7970689
p× 313 × 463 = 4492489
p = 41
p× 89 × 1217 = 4440833 p× 97 × 569 = 2262913
p = 43
p× 67 × 241 = 694321 p× 107 × 461 = 2121061 p× 131 × 257 = 1447681 p× 139 × 1993 = 11912161
p× 157 × 751 = 5070001 p× 199 × 373 = 3191761
p = 47
p× 53 × 499 = 1243009 p× 89 × 103 = 430849 p× 101 × 1583 = 7514501 p× 107 × 839 = 4219331
p× 157 × 239 = 1763581
p = 53
p× 113 × 1997 = 11960033 p× 197 × 233 = 2432753 p× 281 × 877 = 13061161
p = 59
p× 131 × 1289 = 9962681 p× 139 × 821 = 6733021 p× 149 × 587 = 5160317 p× 173 × 379 = 3868453
p× 179 × 353 = 3728033
p = 61
p× 1009 × 2677 = 164766673
=={{header|Kotlin}}==
|