Leetcode 258 Add Digits数论

1 class Solution {
2 public:
3     int addDigits(int num) {
4         if(num == 0 ) return num;
5         else return num % 9 == 0 ? 9 : num % 9;
6     }
7 };

就是数位根!

posted @ 2016-01-15 12:33  Breeze0806  阅读(171)  评论(1编辑  收藏  举报