数学规律:

https://en.wikipedia.org/wiki/Digital_root

 

代码:

public class Solution {
    public int addDigits(int num) {
        return 1+(num-1)%9;
    }
}

  

posted on 2016-01-13 12:13  爱推理的骑士  阅读(117)  评论(0编辑  收藏  举报