Advertisement
Guest User

Untitled

a guest
Mar 21st, 2023
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. def sum_digits(n):
  2. """Return the sum of the digits of positive integer n."""
  3. if n < 10:
  4. return n
  5. else:
  6. all_but_last, last = n // 10, n % 10
  7. return sum_digits(all_but_last) + last
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement