Pan base non-primes: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) (Added Perl) |
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: oops, off-by-one) |
||
Line 487: | Line 487: | ||
say "First 50 pan-base composites:\n" . table 10, @np[0..49]; |
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 "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:" |
say "Count of pan-base composites up to and including $max: ". (my $f = 1 + firstidx { $max <= $_ } @np); |
||
say "Percent odd up to and including $max: " . sprintf '%.3f', 100 * |
say "Percent odd up to and including $max: " . sprintf '%.3f', 100 * (grep { 0 != $_ % 2 } @np[0..$f-1]) / $f; |
||
say "Percent even up to and including $max: " . sprintf '%.3f', 100 * |
say "Percent even up to and including $max: " . sprintf '%.3f', 100 * (grep { 0 == $_ % 2 } @np[0..$f-1]) / $f;</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>First 50 pan-base composites: |
<pre>First 50 pan-base composites: |
||
Line 503: | Line 503: | ||
Count of pan-base composites up to and including 2500: 953 |
Count of pan-base composites up to and including 2500: 953 |
||
Percent odd up to and including 2500: 16. |
Percent odd up to and including 2500: 16.894 |
||
Percent even up to and including 2500: 83. |
Percent even up to and including 2500: 83.106</pre> |
||
=={{header|Phix}}== |
=={{header|Phix}}== |