Pan base non-primes: Difference between revisions

m
→‎{{header|Perl}}: oops, off-by-one
(Added Perl)
m (→‎{{header|Perl}}: oops, off-by-one)
Line 487:
say "First 50 pan-base composites:\n" . table 10, @np[0..49];
say "First 20 odd pan-base composites:\n" . table 10, (grep { 0 != $_ % 2 } @np)[0..19];
say "Count of pan-base composites up to and including $max: " . (1 + (my $f = 1 + firstidx { $max <= $_ } @np));
say "Percent odd up to and including $max: " . sprintf '%.3f', 100 * scalar(grep { 0 != $_ % 2 } @np[0..$f-1]) / $f;
say "Percent even up to and including $max: " . sprintf '%.3f', 100 * scalar(grep { 0 == $_ % 2 } @np[0..$f-1]) / $f;</syntaxhighlight>
{{out}}
<pre>First 50 pan-base composites:
Line 503:
 
Count of pan-base composites up to and including 2500: 953
Percent odd up to and including 2500: 16.912894
Percent even up to and including 2500: 83.193106</pre>
 
=={{header|Phix}}==
2,392

edits