aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-168/massa/raku/ch-1.raku2
-rw-r--r--challenge-168/massa/raku/ch-2.raku28
2 files changed, 30 insertions, 0 deletions
diff --git a/challenge-168/massa/raku/ch-1.raku b/challenge-168/massa/raku/ch-1.raku
new file mode 100644
index 0000000000..d8fd9a0b66
--- /dev/null
+++ b/challenge-168/massa/raku/ch-1.raku
@@ -0,0 +1,2 @@
+use v6;
+(3, 0, 2, * + * + 0 * * ... *).grep(*.is-prime)[^20].sort.unique[^13].say
diff --git a/challenge-168/massa/raku/ch-2.raku b/challenge-168/massa/raku/ch-2.raku
new file mode 100644
index 0000000000..535eaa16fa
--- /dev/null
+++ b/challenge-168/massa/raku/ch-2.raku
@@ -0,0 +1,28 @@
+use v6;
+
+my sub factors(int \x is copy) {
+ my int $possible-factor = 2;
+ gather {
+ while x > 1 {
+ if $possible-factor.is-prime && x %% $possible-factor {
+ take $possible-factor;
+ x div= $possible-factor
+ } else {
+ Nil until is-prime ++$possible-factor
+ }
+ }
+ }
+}
+
+my sub hp(int \x is copy) {
+ loop {
+ given +[~] factors x {
+ .return if .is-prime;
+ x = $_
+ }
+ }
+}
+
+sub MAIN(Int() \n where * > 1) {
+ say hp n
+}