aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander <39702500+threadless-screw@users.noreply.github.com>2019-06-10 14:03:05 +0200
committerGitHub <noreply@github.com>2019-06-10 14:03:05 +0200
commit68c7efea59f5e107c27305a8a084ca1b88867022 (patch)
tree02de718e6c576b23fb1ce1b8076387a6a5e1d046
parente874646e75a09fbe9c9f248e2071bc4182973b7f (diff)
downloadperlweeklychallenge-club-68c7efea59f5e107c27305a8a084ca1b88867022.tar.gz
perlweeklychallenge-club-68c7efea59f5e107c27305a8a084ca1b88867022.tar.bz2
perlweeklychallenge-club-68c7efea59f5e107c27305a8a084ca1b88867022.zip
Create ch-1.p6
-rw-r--r--challenge-012/ozzy/perl6/ch-1.p616
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-012/ozzy/perl6/ch-1.p6 b/challenge-012/ozzy/perl6/ch-1.p6
new file mode 100644
index 0000000000..434880b97f
--- /dev/null
+++ b/challenge-012/ozzy/perl6/ch-1.p6
@@ -0,0 +1,16 @@
+#!/usr/bin/env perl6
+
+my @primes = lazy gather { # Define a lazy array with prime numbers
+ my $a=0;
+ loop { take $a if (++$a).is-prime };
+}
+
+for 1..100 -> $i {
+ my $Euclid = ([*] @primes[0..($i-1)]) +1; # Calculate the $i-th Euclid number.
+ say "E_$i = $Euclid"; # For inspection: show the numbers...
+
+ if ! $Euclid.is-prime { # Print number and exit if it is not-prime.
+ say "$Euclid is not prime!";
+ exit;
+ }
+}