@@ -0,0 +1,500 @@
+package javademo.algorithm;%0A%0A/**%0A *%0A *%0A * Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it.%0A Follow up:%0A Could you do it without any loop/recursion in O(1) runtime?%0A *%0A *%0A */%0Apublic class AddDigits %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A%0A    %7D%0A%0A    /**%0A     * O(1)%E6%97%B6%E9%97%B4%0A     * @param num%0A     * @return%0A     */%0A    public int addDigits(int num) %7B%0A        if (num == 0)%0A            return 0;%0A%0A        return num %25 9 == 0 ? 9 : num %25 9;%0A    %7D%0A%0A%7D%0A

add code-addDigits