@@ -0,0 +1,673 @@
+package com.pengyifan.leetcode;%0A%0A/**%0A * Given a non-negative integer num, repeatedly add all its digits until the result has only one%0A * digit.%0A * %3Cp%3E%0A * For example:%0A * %3Cp%3E%0A * Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return%0A * it.%0A * %3Cp%3E%0A * Follow up:%0A * Could you do it without any loop/recursion in O(1) runtime?%0A */%0Apublic class AddDigits %7B%0A  public int addDigits(int num) %7B%0A    return addDigitsHelper(num);%0A  %7D%0A%0A  private int addDigitsHelper(int num) %7B%0A    if (num %3C 10) %7B%0A      return num;%0A    %7D%0A    int i = 0;%0A    while (num != 0) %7B%0A      i += num %25 10;%0A      num = num / 10;%0A    %7D%0A    return addDigitsHelper(i);%0A  %7D%0A%7D%0A

add digits