aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2021-10-05 06:57:14 +0100
committerdrbaggy <js5@sanger.ac.uk>2021-10-05 06:57:14 +0100
commitb6cea43d6eed00c7a023d2bbcad4186730173b86 (patch)
tree2b78c3ba9ea270d14c15ed8f933ed023c4772f40
parentcf7e0d373a31b67364076a4baad7f4ea27c85152 (diff)
downloadperlweeklychallenge-club-b6cea43d6eed00c7a023d2bbcad4186730173b86.tar.gz
perlweeklychallenge-club-b6cea43d6eed00c7a023d2bbcad4186730173b86.tar.bz2
perlweeklychallenge-club-b6cea43d6eed00c7a023d2bbcad4186730173b86.zip
minor tweak
-rw-r--r--challenge-133/james-smith/perl/ch-2.pl7
1 files changed, 5 insertions, 2 deletions
diff --git a/challenge-133/james-smith/perl/ch-2.pl b/challenge-133/james-smith/perl/ch-2.pl
index 0d19155592..1f07513985 100644
--- a/challenge-133/james-smith/perl/ch-2.pl
+++ b/challenge-133/james-smith/perl/ch-2.pl
@@ -16,7 +16,7 @@ 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 % $_) or ( return $comp{$N} = $comp{$N/$_} + $comp{$_} ) foreach @primes;
+ ( $N % $_) || ( return $comp{$N} = $comp{$N/$_} + $comp{$_} ) foreach @primes;
## Otherwise we are prime so add to primes and return nothing....
$comp{$N} = sum_digits $N;
@@ -32,10 +32,13 @@ sub smith_numbers { ## This is the short form! using &&
( return @sn ) while $n++;
}
+## Same functions without comments....
+
sub cl_sum_digits { my $t = 0; $t+=$_ foreach split //, $_[0]; $t }
+
sub cl_sum_prime_factors {
my $N = shift;
- ( $N % $_) or ( return $comp{$N} = $comp{$N/$_} + $comp{$_} ) foreach @primes;
+ ( $N % $_) || ( return $comp{$N} = $comp{$N/$_} + $comp{$_} ) foreach @primes;
$comp{$N} = cl_sum_digits $N;
push @primes, $N;
return 0;