Advertisement
MatveyL

сумма цифр

Dec 5th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. sum = 0
  2. def popa1(a,b):
  3. if a//b > 0:
  4. return popa1(a,b*10)
  5. else:
  6. return b
  7. def popa2(a,b):
  8. global sum
  9. sum += a//b
  10. a= a - ((a//b)*b)
  11. b = b // 10
  12. if b < 1:
  13. return sum
  14. else:
  15. return popa2(a,b)
  16. a = int(input())
  17. f = popa1(a,1 )
  18. print(popa2(a,f))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement