diff options
| author | Joelle Maslak <jmaslak@antelope.net> | 2019-04-14 14:34:36 -0500 |
|---|---|---|
| committer | Joelle Maslak <jmaslak@antelope.net> | 2019-04-14 14:34:36 -0500 |
| commit | dcd5dc8d7f0e8cec0e329f8abadbdfcc583fdfa3 (patch) | |
| tree | 87ffa0ce6fce5aef0d310d095ee47803aec583b3 /challenge-003 | |
| parent | 01defbf5c53be4bf6a99de1ebe254bc1920cf3ca (diff) | |
| download | perlweeklychallenge-club-dcd5dc8d7f0e8cec0e329f8abadbdfcc583fdfa3.tar.gz perlweeklychallenge-club-dcd5dc8d7f0e8cec0e329f8abadbdfcc583fdfa3.tar.bz2 perlweeklychallenge-club-dcd5dc8d7f0e8cec0e329f8abadbdfcc583fdfa3.zip | |
Allow specifying number count on command line
Diffstat (limited to 'challenge-003')
| -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; } |
