RosettaCodeData/Task/Arithmetic-numbers/Raku/arithmetic-numbers.raku

12 lines
475 B
Raku
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
use Prime::Factor;
use Lingua::EN::Numbers;
my @arithmetic = lazy (1..).hyper.grep: { my @div = .&divisors; @div.sum %% @div }
say "The first { .Int.&cardinal } arithmetic numbers:\n", @arithmetic[^$_].batch(10)».fmt("%{.chars}d").join: "\n" given 1e2;
for 1e3, 1e4, 1e5, 1e6 {
say "\nThe { .Int.&ordinal }: { comma @arithmetic[$_-1] }";
say "Composite arithmetic numbers { comma @arithmetic[$_-1] }: { comma +@arithmetic[^$_].grep({!.is-prime}) - 1 }";
}