aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-139/luca-ferrari/raku/ch-2.p616
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-139/luca-ferrari/raku/ch-2.p6 b/challenge-139/luca-ferrari/raku/ch-2.p6
new file mode 100644
index 0000000000..a7f35ef47e
--- /dev/null
+++ b/challenge-139/luca-ferrari/raku/ch-2.p6
@@ -0,0 +1,16 @@
+#!raku
+
+sub MAIN( Int $limit where { $limit >= 1 } = 5 ) {
+ my @solutions;
+ for 1 .. Inf {
+ next if ! $_.is-prime;
+ my $repeating-size = $_ - 1;
+ my $repeating-part = ( 1 / $_ ).Rat.base-repeating( 10 )[ 1 ];
+ next if ! $repeating-part;
+
+ @solutions.push: $_ if $repeating-part.Str.chars == $repeating-size;
+ last if @solutions.elems == $limit;
+ }
+
+ @solutions.join( ', ' ).say;
+}