最小公倍数

作者:David Romano

https://projecteuler.net/problem=5

2520 是可以被 1 到 10 的每个数字整除的最小数字。

能被 1 到 20 的所有数字整除的最小正数是多少?

源代码:prob005-unobe.pl

use v6;

my @numbers = 2..20;
my @factors = @numbers;
my %factor;
for @numbers -> $num is rw {
    for @factors -> $factor is rw {
        next if $num % $factor;
        my $exp = 0;
        while $num div= $factor { $exp++; }
        if !%factor{$factor} || %factor{$factor} < $exp {
            %factor{$factor} = $exp;
        };
    }
}
say [*] %factor.map({ .key**.value });