aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-141/luca-ferrari/raku/ch-1.p619
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-141/luca-ferrari/raku/ch-1.p6 b/challenge-141/luca-ferrari/raku/ch-1.p6
new file mode 100755
index 0000000000..621db2a13e
--- /dev/null
+++ b/challenge-141/luca-ferrari/raku/ch-1.p6
@@ -0,0 +1,19 @@
+#!raku
+
+
+sub MAIN( Int $divisors = 8, Int $count = 10 ) {
+
+ "Searching $count numbers with $divisors divisors...".say;
+
+ my %solutions;
+
+ for $divisors + 1 .. Inf -> $current-number {
+ my @intra-solutions = ( 1 .. $current-number ).grep( { $current-number %% $_ } );
+
+ %solutions{ $current-number } = @intra-solutions if @intra-solutions.elems == $divisors;
+
+ last if %solutions.keys.elems >= $count;
+ }
+
+ "$_ has $divisors divisors: { %solutions{ $_ }.join( ', ' ) }".say for %solutions.keys.sort;
+}