258. Add Digits
Digit Root number problem
/**/varfunction(num ) {var b = (num-1)% 9 + 1 ; return b;};
The reason NUM is 1 to +1 is because of the special case: when NUM is a multiple of 9, the number root of 0+9 is different from the number root of 0.
Description of Nature 1. Any number plus 9 of the number root is still itself. (Special case num=0) when elementary school is added, we all understand that a number plus 9 is the sum of ten plus 1, and you subtract 1. So 10 bits plus bit is constant, if there is a carry, that is, 10 is 9, then the carry 10 will become 0, the hundred will add 1, the truth and a one-digit plus 9 is the same. 2.9 times the number root of any number is 9. When we were studying multiplication in primary school, we were calculating a number of times by nine, and 10 fingers were lined up, and the number of fingers in front and back was the result. Its digital roots are always 10-1=9. Multi-digit, split every bit of the number.
Leetcode JavaScript Solution 258. ADD Digits