//Java写法 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNextInt()) { int n = sc.nextInt(); while (n > 9) { int sum = 0; int temp = n; while (temp > 0) { sum += temp % 10; temp /= 10; } n = sum; } System.out.println(n); } } } #Python写法 while True: try: n = int(input()) while n > 9: n = sum(map(int, str(n))) print(n) except: break