aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Lynn <bizlsg@localhost.localdomain>2022-06-13 19:50:16 +0800
committerStephen Lynn <bizlsg@localhost.localdomain>2022-06-13 19:50:16 +0800
commit6c11579380e6eca2b8726e33fdf622fc15328ca7 (patch)
tree7d0b305ae4e230275ed5d0be378462fd1c8b10fc
parent8810e3636cb9c2a1b553481bf3b4ae1fc3841784 (diff)
downloadperlweeklychallenge-club-6c11579380e6eca2b8726e33fdf622fc15328ca7.tar.gz
perlweeklychallenge-club-6c11579380e6eca2b8726e33fdf622fc15328ca7.tar.bz2
perlweeklychallenge-club-6c11579380e6eca2b8726e33fdf622fc15328ca7.zip
ch-1
-rwxr-xr-xchallenge-169/steve-g-lynn/perl/ch-1.pl31
-rwxr-xr-xchallenge-169/steve-g-lynn/raku/ch-1.p622
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);
+
+