aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-133/james-smith/perl/ch-2.pl6
1 files changed, 4 insertions, 2 deletions
diff --git a/challenge-133/james-smith/perl/ch-2.pl b/challenge-133/james-smith/perl/ch-2.pl
index 053d890468..b8f5fc1ec8 100644
--- a/challenge-133/james-smith/perl/ch-2.pl
+++ b/challenge-133/james-smith/perl/ch-2.pl
@@ -16,7 +16,8 @@ sub sum_prime_factors {
my $N = shift;
## If we are composite then store the sum of the digit factors for the composite and return...
- ( $N % $_) ? (( $N<$_*$_) && last ) : ( return $sum_pf[$N] = $sum_pf[$N/$_] + $sum_pf[$_] )
+ ( $N % $_) ? (( $N<$_*$_) && last )
+ : ( return $sum_pf[$N] = $sum_pf[$N/$_] + $sum_pf[$_] )
foreach @primes;
## Otherwise we are prime so add to primes and return nothing....
@@ -40,7 +41,8 @@ sub cl_sum_digits { my $t = 0; $t+=$_ foreach split //, $_[0]; $t }
sub cl_sum_prime_factors {
my $N = shift;
- ( $N % $_) || ( return $sum_pf[$N] = $sum_pf[$N/$_] + $sum_pf[$_] ) foreach @primes;
+ ( $N % $_) ? (( $N<$_*$_) && last )
+ : ( return $sum_pf[$N] = $sum_pf[$N/$_] + $sum_pf[$_] ) foreach @primes;
$sum_pf[$N] = cl_sum_digits $N;
push @primes, $N;
return 0;