From 68c7efea59f5e107c27305a8a084ca1b88867022 Mon Sep 17 00:00:00 2001 From: Alexander <39702500+threadless-screw@users.noreply.github.com> Date: Mon, 10 Jun 2019 14:03:05 +0200 Subject: Create ch-1.p6 --- challenge-012/ozzy/perl6/ch-1.p6 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 challenge-012/ozzy/perl6/ch-1.p6 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; + } +} -- cgit