fork download
  1. def sum_tail(n, s = 0):
  2.  
  3. if n == 0:
  4.  
  5. return s
  6.  
  7. else:
  8.  
  9. return sum(n // 10, n % 10 + s)
  10.  
  11. def sum( n ):
  12.  
  13. if n == 0:
  14.  
  15. return 0
  16.  
  17. else:
  18.  
  19. return n % 10 + sum(n // 10)
  20.  
  21.  
  22. def main():
  23.  
  24. n = int(input("n="))
  25.  
  26. print(sum_tail(n))
  27.  
  28. main()
Runtime error #stdin #stdout #stderr 0.15s 23592KB
stdin
12345
stdout
n=
stderr
Traceback (most recent call last):
  File "./prog.py", line 28, in <module>
  File "./prog.py", line 26, in main
  File "./prog.py", line 9, in sum_tail
TypeError: sum() takes 1 positional argument but 2 were given