title: Java program recursion is not working
body: <p>I am trying to produce a series of sum of digit of previous terms 
  <a href="https://oeis.org/A004207" rel="nofollow">https://oeis.org/A004207</a></p>
  
  <p>1, 1, 2, 4, 8, 16, 23, 28, 38, 49, 62, 70, 77, 91, 101, 103, 107, 115, 122, 127,</p>
  
  <p>This is the code I have got </p>
  
  <pre><code>import java.math.BigInteger;
  import java.util.ArrayList;
  public class Problem {
          public static int getDigitSum(int number) {
              int total = 0;
              while ( number&gt;0) {
                  total +=  total + number%10;
                  number = number /10;         
  
  
          }
        return total;
      }
  
  
      public static int getSum(int number) {
      if ((number == 0) || (number == 1)) // base cases
        return number;
      else
        // recursion step
        return getSum(getDigitSum(number - 1)) +  getSum(number - 2);
    } 
  
      public static void main( String s []) {
          int sum =0, difference=1, previous =1, last;
          //ArrayList &lt;Integer&gt; sum_list =  new ArrayList &lt;Integer&gt;();
          //sum_list.add(prevous);
          for (int i = 1; i&lt;10; i++) {
              System.out.println(getSum(i));
          }
      }
  }
  </code></pre>
  
  <p>This code produce wrong output</p>
  
  <pre><code>    1
  1
  2
  3
  5
  8
  13
  21
  34
  </code></pre>