title: Decreasing value and then unexpected increase of value with recursion
body: <p>I am trying to learn recursion and it acts really strange. I have the below simple method to decrease the given value and sum the even numbers until the value goes to 0. However once the value = 0, somehow it starts accessing just the recursive call (which is in an IF-ELSE condition) and starts increasing my value back and adding again until it reaches back to the initial value. I recorded 2 screencasts. If I create a main method within the class and execute the method with 5, for example, I receive output 6, which is correct, however in the JUnit test for the same value, it expects <strong>6</strong>, but the actual value is <strong>64</strong>! I am not sure what I'm doing wrong. Also, once the value reaches 0, am I returning the correct thing? I wasn't sure how to return the sum there but at the same time have the sum returned as output of the method itself.. </p>
  
  <pre><code>class EvenSums {
    private static int sum = 0;
  
    public static int sumEvenRec(int n) {
    int input = n;
  
    if(input &lt;= 0) {
        return 0;
    } else {
        if(input % 2 == 0) {
            sum += input;
        }
        sumEvenRec(input-1);
    }
    return sum;
  }
  </code></pre>
  
  <p>Here's the Debug screencast (Note the decreasing and then increasing value of input) and note how it goes from return sum back to the recursive function which somehow increases the value of the input. 
  <strong><a href="https://streamable.com/gkoq5" rel="nofollow noreferrer">DEBUG SCREENCAST</a></strong></p>
  
  <p>On the test screencast you can see: <br>
  For input 2: <code>java.lang.AssertionError: expected:&lt;2&gt; but was:&lt;58&gt;</code> <br>
  For input 5: <code>java.lang.AssertionError: expected:&lt;6&gt; but was:&lt;64&gt;</code> <br>
  For input 6: <code>java.lang.AssertionError: expected:&lt;12&gt; but was:&lt;76&gt;</code> <br>
  <br>
  Intrestingly, For input <strong>15</strong>: <strong>works</strong>! <br>
  <strong><a href="https://streamable.com/gmni7" rel="nofollow noreferrer">TEST SCREENCAST</a></strong></p>