Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sum_digits(n):
- """Return the sum of the digits of positive integer n."""
- if n < 10:
- return n
- else:
- all_but_last, last = n // 10, n % 10
- return sum_digits(all_but_last) + last
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement