Anti-primes: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (→{{header|Perl 6 }}: Add a Perl 6 example) |
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Add some hyphens) |
||
Line 79: | Line 79: | ||
my atomicint $last = 0; |
my atomicint $last = 0; |
||
my @ |
my @anti-primes = lazy 1, |(|(2..989), 990, *+30 …^ *).hyper.grep: -> $c { |
||
my \mx = +propdiv($c); |
my \mx = +propdiv($c); |
||
next if mx <= $last; |
next if mx <= $last; |
||
Line 88: | Line 88: | ||
my $upto = 5e5; |
my $upto = 5e5; |
||
put "First 20 |
put "First 20 anti-primes:\n{ @anti-primes[^20] }"; |
||
put "\nCount of |
put "\nCount of anti-primes <= $upto: {+@anti-primes[^(@anti-primes.first: * > $upto, :k)]}";</lang> |
||
{{out}} |
{{out}} |
||
<pre>First 20 |
<pre>First 20 anti-primes: |
||
1 2 4 6 12 24 36 48 60 120 180 240 360 720 840 1260 1680 2520 5040 7560 |
1 2 4 6 12 24 36 48 60 120 180 240 360 720 840 1260 1680 2520 5040 7560 |
||
Count of |
Count of anti-primes <= 500000: 36</pre> |
||
=={{header|Python}}== |
=={{header|Python}}== |