22a. Sum Digits
Sum the digits in a number.
sum-digits
: whole-number -> number
Find the sum of the digits in a number.
n | (sum-digits n) |
simplified |
---|---|---|
5 | 5 | 5 |
53 | 5 + 3 | 8 |
921 | 9 + 2 + 1 | 12 |
3216 | 3 + 2 + 1 + 6 | 12 |
65536 | 6 + 5 + 5 + 3 + 6 | 25 |