Wilson primes of order n: Difference between revisions
julia example
m (Repaired Wren entry.) |
(julia example) |
||
Line 79:
11: 17 2713
</pre>
=={{header|Julia}}==
{{trans|Wren}}
<lang julia>using Primes
function wilsonprimes(limit = 11000)
sgn, facts = 1, accumulate(*, 1:limit, init = big"1")
println(" n: Wilson primes\n--------------------")
for n in 1:11
print(lpad(n, 2), ": ")
sgn = -sgn
for p in primes(limit)
if p > n
if (facts[n < 2 ? 1 : n - 1] * facts[p - n] - sgn) % p^2 == 0
print("$p ")
end
end
end
println()
end
end
wilsonprimes()
</lang>
Output: Same as Wren example.
=={{header|Nim}}==
|