Permalink
Browse files

work on two implementations of 012, but these do not yet appear to ha…

…ve finite runtime
  • Loading branch information...
1 parent 83e1de5 commit d6fb35eec8c2287a78bfe96c8d2628cf06d6d749 @rbuels rbuels committed Aug 11, 2009
Showing with 44 additions and 0 deletions.
  1. +28 −0 perl5/012/01.pl
  2. +16 −0 perl6/012/01.pl
View
28 perl5/012/01.pl
@@ -0,0 +1,28 @@
+my $current_triangle_num = 1;
+my $counter = 1;
+
+while( my $div_ct = count_divisors($current_triangle_num) and $div_ct < 500 ) {
+ #say "$current_triangle_num has $div_ct divisors\n";
+ $current_triangle_num += ++$counter;
+}
+say $current_triangle_num;
+
+sub count_divisors {
+ my $num = shift;
+
+ my $candidate_divisor = $num;
+ my $divisor_count = 0;
+
+ #my @divisors;
+ while( $candidate_divisor > 0 ) {
+ if( $num % $candidate_divisor == 0 ) {
+ $divisor_count++;
+ #unshift @divisors, $candidate_divisor;
+ }
+ $candidate_divisor--;
+ }
+
+ #say "$num\n".join(',',@divisors);
+
+ return $divisor_count;
+}
View
16 perl6/012/01.pl
@@ -0,0 +1,16 @@
+my $current_triangle_num = 0;
+my $counter = 0;
+
+while( num_factors($current_triangle_num) <= 500 ) {
+ $current_triangle_num += ++$counter;
+}
+say $current_triangle_num;
+
+sub count_factors($num) {
+ my $candidate_factor = $num;
+ my $factor_count = 0;
+
+ while( $candidate_factor-- % $num == 0 ) {
+
+ }
+}

0 comments on commit d6fb35e

Please sign in to comment.