E 方法1: 普通做法就是按照题意, 把每个digit加起来. O(n) 方法2: 找数学规律, 每过9个数字, 取mod就会开始重复, 所以给所有数字取mod 就可以间接找到答案. ``` /* Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it. Follow up: Could you do it without any loop/recursion in O(1) runtime? */ class Solution { public int addDigits(int num) { return (num - 1) % 9 + 1; } } ```