Super-Poulet numbers: Difference between revisions
Content added Content deleted
(julia example) |
|||
Line 17: | Line 17: | ||
;*[[oeis:A050217|OEIS:A050217 - super-Poulet numbers]] |
;*[[oeis:A050217|OEIS:A050217 - super-Poulet numbers]] |
||
++{{header|Julia}}== |
|||
<lang ruby>using Primes |
|||
divisors(n) = @view sort!(vec(map(prod, Iterators.product((p.^(0:m) for (p, m) in eachfactor(n))...))))[begin:end-1] |
|||
issuperPoulet(n) = !isprime(n) && big"2"^(n - 1) % n == 1 && all(d -> (big"2"^d - 2) % d == 0, divisors(n)) |
|||
spoulets = filter(issuperPoulet, 1:12_000_000) |
|||
println("The first 20 super-Poulet numbers are: ", spoulets[1:20]) |
|||
idx1m = findfirst(>(1_000_000), spoulets) |
|||
idx10m = findfirst(>(10_000_000), spoulets) |
|||
println("The first super-Poulet number over 1 million is the ", idx1m, "th one, which is ", spoulets[idx1m]) |
|||
println("The first super-Poulet number over 10 million is the ", idx10m, "th one, which is ", spoulets[idx10m]) |
|||
</lang>{{out}} |
|||
<pre> |
|||
The first 20 super-Poulet numbers are: [341, 1387, 2047, 2701, 3277, 4033, 4369, 4681, 5461, 7957, 8321, 10261, 13747, 14491, 15709, 18721, 19951, 23377, 31417, 31609] |
|||
The first super-Poulet number over 1 million is the 109th one, which is 1016801 |
|||
The first super-Poulet number over 10 million is the 317th one, which is 10031653 |
|||
</pre> |
|||
=={{header|Phix}}== |
=={{header|Phix}}== |