fork download
  1. class num:
  2. def __init__(self, v):
  3. self.val = int(v)
  4. self.sz = len(v)
  5. def ignite(self):
  6. tong = 0
  7. for i in str(self.val):
  8. tong += int(i)
  9. self.val = tong
  10. self.sz = len(str(self.val))
  11. n = num(input())
  12. while n.sz > 1:
  13. n.ignite()
  14. print(n.val)
  15.  
Success #stdin #stdout 0.1s 14032KB
stdin
991
stdout
1