diff options
| -rwxr-xr-x | challenge-169/steve-g-lynn/perl/ch-1.pl | 31 | ||||
| -rwxr-xr-x | challenge-169/steve-g-lynn/raku/ch-1.p6 | 22 |
2 files changed, 53 insertions, 0 deletions
diff --git a/challenge-169/steve-g-lynn/perl/ch-1.pl b/challenge-169/steve-g-lynn/perl/ch-1.pl new file mode 100755 index 0000000000..c37dfe2676 --- /dev/null +++ b/challenge-169/steve-g-lynn/perl/ch-1.pl @@ -0,0 +1,31 @@ +#!/usr/bin/perl + +#-- generate 1st 20 brilliant numbers +#-- product of two prime factors of same length + +use Math::Prime::Util qw(primes); + +my @brilliants = (); + +for $i (1,2) { # get 1 or 2 digit primes with each iteration + my $ra=primes(10**($i-1), 10**($i)); + + for $i (0 .. @$ra-1) { + for $j ($i .. @$ra-1) { + push (@brilliants, + $$ra[$i] * $$ra[$j] ); + } + } +} + +@brilliants = sort{$a <=> $b} @brilliants; + +foreach (0 .. 19) { + print $brilliants[$_]," "; +} + +print "\n"; + + + + diff --git a/challenge-169/steve-g-lynn/raku/ch-1.p6 b/challenge-169/steve-g-lynn/raku/ch-1.p6 new file mode 100755 index 0000000000..9042bc0854 --- /dev/null +++ b/challenge-169/steve-g-lynn/raku/ch-1.p6 @@ -0,0 +1,22 @@ +#!/usr/bin/raku + +#-- generate 1st 20 brilliant numbers +#-- product of two prime factors of same length + +my @brilliants = (); + +for (1,2) -> $i { + my @a = (2..1000). + grep(*.is-prime). + grep(*.Str.chars==$i); + + for (0 .. @a.elems-1) -> $i { + for ($i .. @a.elems-1) -> $j { + @brilliants.append(@a[$i]*@a[$j]); + } + } +} + +say @brilliants.sort.head(20); + + |
