Jump to content

Pan base non-primes: Difference between revisions

m
→‎{{header|Raku}}: make code match output
m (→‎{{header|Raku}}: make code match output)
Line 112:
my @np = 4,6,8,9, |lazy (11..*).hyper.grep( -> $n { ($n.substr(*-1) eq '0') || (1 < [gcd] $n.comb».Int) || none (2..$n).map: { try "$n".&from-base($_).is-prime } } );
 
put "First 50 pan-base non-primescomposites:\n" ~ @np[^50].batch(10)».fmt("%3s").join: "\n";
put "\nFirst 20 odd pan-base non-primescomposites:\n" ~ @np.grep(* % 2)[^20].batch(10)».fmt("%3s").join: "\n";
 
my $threshold = 2500;
put "\nCount of pan-base non-primescomposites up to and including $threshold: " ~ +@np.&upto($threshold);
 
put "Percent odd up to and including $threshold: " ~ +@np.&upto($threshold).grep(* % 2) / +@np.&upto($threshold) × 100;
10,333

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.