diff options
| author | Jörg Sommrey <28217714+jo-37@users.noreply.github.com> | 2022-06-23 23:44:29 +0200 |
|---|---|---|
| committer | Jörg Sommrey <28217714+jo-37@users.noreply.github.com> | 2022-06-24 17:58:32 +0200 |
| commit | 5350d5137dd357b48464fdbfff74c967d8ee2cd0 (patch) | |
| tree | 556832264f0b81cc6c925817056bae7751831b14 | |
| parent | 247e5a8ccbf2ca49929f435a6efc5e7f9c6e4e36 (diff) | |
| download | perlweeklychallenge-club-5350d5137dd357b48464fdbfff74c967d8ee2cd0.tar.gz perlweeklychallenge-club-5350d5137dd357b48464fdbfff74c967d8ee2cd0.tar.bz2 perlweeklychallenge-club-5350d5137dd357b48464fdbfff74c967d8ee2cd0.zip | |
Solution to task 1
| -rwxr-xr-x | challenge-170/jo-37/perl/ch-1.pl | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-170/jo-37/perl/ch-1.pl b/challenge-170/jo-37/perl/ch-1.pl new file mode 100755 index 0000000000..db3b1bbd91 --- /dev/null +++ b/challenge-170/jo-37/perl/ch-1.pl @@ -0,0 +1,24 @@ +#!/usr/bin/perl -s + +use v5.16; +use warnings; +use Math::Prime::Util 'prime_iterator'; +use List::Util 'reductions'; + +die <<EOS unless @ARGV; +usage: $0 N + +N + Print the first N primorials. + +EOS + + +# Math::Prime::Util has 'primorial', but as the *sequence* of the first +# N primorials is requested in this task, another approach seems to be +# more useful: Build the sequence of the first N-1 primes' product. + +main: { + my $pi = prime_iterator(); + say for reductions {$a * $b} 1, map $pi->(), 2 .. shift; +} |
