diff options
| -rwxr-xr-x[-rw-r--r--] | challenge-003/joelle-maslak/perl6/ch-1.p6 | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/challenge-003/joelle-maslak/perl6/ch-1.p6 b/challenge-003/joelle-maslak/perl6/ch-1.p6 index d9649489c7..f93e7683ab 100644..100755 --- a/challenge-003/joelle-maslak/perl6/ch-1.p6 +++ b/challenge-003/joelle-maslak/perl6/ch-1.p6 @@ -2,8 +2,10 @@ use v6; -my @hamming = (1..∞).grep: { divisors($^num).grep( *.is-prime ).Set ⊆ (2,3,5).Set }; -say "Hamming numbers [0..4]: " ~ @hamming[^5].join(", "); +sub MAIN(Int:D $count where * ≥ 0) { + my @hamming = (1..∞).grep: { divisors($^num).grep( *.is-prime ).Set ⊆ (2,3,5).Set }; + say "Hamming numbers [0..{$count-1}]: " ~ @hamming[^$count].join(", "); +} sub divisors(Int:D $i -->Array[Int:D]) { if ($i == 0) { return 0; } |
