【Leetcode】Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.

三种情况:

1 num=0,return0

2 num是9的倍数,return9

3 其余返回num%9

你可能感兴趣的:(【Leetcode】Add Digits)