Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. def sumDigits(n):
  2. sum = 0
  3. while n > 0:
  4. sum += n % 10
  5. n //= 10
  6. return sum
  7.  
  8. while n > 0:
  9. sum += n % 10 # Why n % 10?
  10. n //= 10 # Again, not sure why we divide the number by 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement