fork download
  1. arr = []
  2. arr = input()
  3. arr = arr.split()
  4. print(*arr, sep = ", ")
  5.  
  6. for i in arr:
  7. g = int(i)
  8. sum = 10
  9. cycle = 0
  10. while sum > 9:
  11. if(g < 10):
  12. break
  13. sum = 0
  14. while g > 0:
  15. u = g%10
  16. sum += u
  17. g -= u
  18. g /= 10
  19. g = sum
  20. cycle +=1
  21. print("AP(", end = "")
  22. print(i, end = "")
  23. print(") = ", end = "")
  24. if(i == arr[-1]):
  25. print(cycle, end = "")
  26. else:
  27. print(cycle)
Success #stdin #stdout 0.02s 9912KB
stdin
1 3 5 6 21 28
stdout
1, 3, 5, 6, 21, 28
AP(1) = 0
AP(3) = 0
AP(5) = 0
AP(6) = 0
AP(21) = 1
AP(28) = 2