https://leetcode.com/problems/add-digits/#/description
这其实算数学题,有现成的公式可以用。
https://en.wikipedia.org/wiki/Digital_root#Congruence_formula
public class Solution { public int addDigits(int num) { return 1 + (num - 1) % 9; } }
Last updated 5 years ago