boris-vlasenko

Цифровой корень

Oct 2nd, 2015
945
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.17 KB | None | 0 0
  1. n = int(input())
  2. s = 0
  3. end = False
  4. while not end:
  5.     s += n % 10
  6.     n = n // 10
  7.     if n == 0:
  8.         if s < 10:
  9.             end = True
  10.         else:
  11.             n = s
  12.             s = 0
  13.    
  14. print(s)
Advertisement
Add Comment
Please, Sign In to add comment