Super-Poulet numbers: Difference between revisions
Content added Content deleted
m (→{{header|J}}) |
m (Python example) |
||
Line 129: | Line 129: | ||
The 317th super-Poulet number is 10,031,653 and the first > 1e+7 |
The 317th super-Poulet number is 10,031,653 and the first > 1e+7 |
||
</pre> |
</pre> |
||
=={{header|Python}}== |
|||
{{trans|Julia}} |
|||
<lang python>from sympy import isprime, divisors |
|||
def is_super_Poulet(n): |
|||
return not isprime(n) and 2**(n - 1) % n == 1 and all((2**d - 2) % d == 0 for d in divisors(n)) |
|||
spoulets = [n for n in range(1, 1_100_000) if is_super_Poulet(n)] |
|||
print('The first 20 super-Poulet numbers are:', spoulets[:20]) |
|||
idx1m, val1m = next((i, v) for i, v in enumerate(spoulets) if v > 1_000_000) |
|||
print(f'The first super-Poulet number over 1 million is the {idx1m}th one, which is {val1m}') |
|||
</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 108th one, which is 1016801 |
|||
</pre> |
|||
=={{header|Raku}}== |
=={{header|Raku}}== |