aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]challenge-141/jake/perl/ch-1.pl24
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-141/jake/perl/ch-1.pl b/challenge-141/jake/perl/ch-1.pl
index 711f5cf4f7..13e4c85102 100644..100755
--- a/challenge-141/jake/perl/ch-1.pl
+++ b/challenge-141/jake/perl/ch-1.pl
@@ -2,3 +2,27 @@
use warnings;
use strict;
+use feature 'say';
+
+my $number_attributes = {
+ number => '1',
+ divisor_counter => '0',
+ subtractor => '0',
+};
+count_divisors( $number_attributes );
+# modulo number n through n, n-1, and so on
+# for each modulo 0 increase counter
+# when counter hits 8 add number to number array, proceed to next number and increase number counter
+# if number counter hits 10 output number array or if array size becomes 10
+
+sub count_divisors {
+ say ( $number_attributes->{divisor_counter}, $number_attributes->{subtractor}, $number_attributes->{number} );
+ while ( $number_attributes->{divisor_counter} < 9 ) {
+ say ( $number_attributes->{divisor_counter}, $number_attributes->{subtractor}, $number_attributes->{number} );
+ $number_attributes->{divisor_counter}++ if $number_attributes->{number} % ( $number_attributes->{number} - $number_attributes->{subtractor} ) == 0;
+ $number_attributes->{subtractor}++;
+ print "div_c: $number_attributes->{divisor_counter}, subtr: $number_attributes->{subtractor}\n";
+ $number_attributes->{number}++;
+ die if $number_attributes->{number} == 10;
+ }
+} \ No newline at end of file