aboutsummaryrefslogtreecommitdiff
path: root/challenge-133/james-smith
diff options
context:
space:
mode:
authorJames Smith <baggy@baggy.me.uk>2021-10-04 21:59:07 +0100
committerGitHub <noreply@github.com>2021-10-04 21:59:07 +0100
commitc1c6f76abdb9cef32be0cc0699fd5aecbd6fbfda (patch)
tree611a145036ffb694a45a372932c29b2c9fa0f11b /challenge-133/james-smith
parentb6903807fb8e0dd8ec65303adc7f65d64a48cc19 (diff)
downloadperlweeklychallenge-club-c1c6f76abdb9cef32be0cc0699fd5aecbd6fbfda.tar.gz
perlweeklychallenge-club-c1c6f76abdb9cef32be0cc0699fd5aecbd6fbfda.tar.bz2
perlweeklychallenge-club-c1c6f76abdb9cef32be0cc0699fd5aecbd6fbfda.zip
Update README.md
Diffstat (limited to 'challenge-133/james-smith')
-rw-r--r--challenge-133/james-smith/README.md8
1 files changed, 8 insertions, 0 deletions
diff --git a/challenge-133/james-smith/README.md b/challenge-133/james-smith/README.md
index 90f596e9e0..e467044ffc 100644
--- a/challenge-133/james-smith/README.md
+++ b/challenge-133/james-smith/README.md
@@ -52,6 +52,14 @@ sub smith_numbers {
}
```
+And the support functions:
+ * `sum` - Just sum an array;
+ * `sum_digits` - Sum digits of number,
+ We cache the digit sum for each number in `%ds`;
+ * `prime_factors` - for a prime returns nothing, for a composite returns the factors,
+ We keep a list of primes `@primes`, and also the prime factors for each composite `%comp`.
+
+```perl
sub sum { my $t = 0; $t+=$_ foreach @_; $t; }
sub sum_digits { return $ds{$_[0]} ||= sum split //, $_[0]; }