Super-Poulet numbers: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (Thundergnat moved page Super-Poulet number to Super-Poulet numbers: Should be plural) |
Thundergnat (talk | contribs) m (Meh, fix case errors) |
||
Line 1:
{{draft task}}
A [[wp:Super-Poulet_number|
;Task
* Find and display the first '''20'''
;Stretch
* Find and display the index and value of the first
;See also
;*[[Fermat pseudoprimes|Task: Fermat pseudoprimes]]
;*[[wp:Super-Poulet_number|Wikipedia:
;*[[oeis:A050217|OEIS:A050217 -
Line 25:
my @super-poulet = @poulet.grep: { all .&divisors.skip(1).map: { 2 == expmod 2, $_, $_ } }
say "First 20
for 1e6.Int, 1e7.Int -> $threshold {
say "\nIndex and value of first
my $index = @super-poulet.first: * > $threshold, :k;
say "{(1+$index).&ordinal-digit}
}</lang>
{{out}}
<pre>First 20
(341 1387 2047 2701 3277 4033 4369 4681 5461 7957 8321 10261 13747 14491 15709 18721 19951 23377 31417 31609)
Index and value of first
109th
Index and value of first
317th
</pre>
|
Revision as of 00:00, 17 August 2022
Super-Poulet numbers is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
A super-Poulet number is a Poulet number (or Fermat pseudoprime to base 2) whose every divisor d evenly divides 2d − 2.
- Task
- Find and display the first 20 super-Poulet numbers.
- Stretch
- Find and display the index and value of the first super-Poulet number greater than one million.
- See also
Raku
<lang perl6>use Prime::Factor; use Lingua::EN::Numbers;
my @poulet = lazy (2..*).hyper(:2000batch).grep: { !.is-prime && (1 == expmod 2, $_ - 1, $_) } my @super-poulet = @poulet.grep: { all .&divisors.skip(1).map: { 2 == expmod 2, $_, $_ } }
say "First 20 super-Poulet numbers:\n" ~ @super-poulet[^20].gist;
for 1e6.Int, 1e7.Int -> $threshold {
say "\nIndex and value of first super-Poulet greater than {$threshold.&cardinal}:"; my $index = @super-poulet.first: * > $threshold, :k; say "{(1+$index).&ordinal-digit} super-Poulet number == " ~ @super-poulet[$index].,
}</lang>
- Output:
First 20 super-Poulet numbers: (341 1387 2047 2701 3277 4033 4369 4681 5461 7957 8321 10261 13747 14491 15709 18721 19951 23377 31417 31609) Index and value of first super-Poulet greater than one million: 109th super-Poulet number == 1,016,801 Index and value of first super-Poulet greater than ten million: 317th super-Poulet number == 10,031,653