fork(1) download
  1. def digit_sum(n):
  2. sum = 0
  3. new_n = n
  4. while new_n > 10:
  5. s = n%10
  6. new_n = (new_n - s)//10
  7. sum = sum + s
  8. else:
  9. sum = sum + new_n
  10. print (sum)
  11.  
  12. #z = int (input ("Введите число:"))
  13. digit_sum(2564)
Success #stdin #stdout 0.03s 44680KB
stdin
Standard input is empty
stdout
14