title: Java recursion sum of odd even
body: <p>I have to write a java code (its not a homework ) </p>
  
  <p>We take a method int n and we return :</p>
  
  <p>If (n positive and odd )--> 1+3+5+...+n</p>
  
  <p>If (n positive and even) --> 2+4+6+..+n </p>
  
  <p>If (n negative or zero) --> return 0</p>
  
  <p>I know how to do these three separately,but together? </p>
  
  <p>For example If (n positive and even) --> 2+4+6+..+n </p>
  
  <pre><code>public int addeven(int n)
   {
    if(n&lt;0)
    {
      return 0;    
    }
    if(n%2 != 0 &amp;&amp; n&gt;0 )
    {
      return (n+addeven(n-1));
    }
  
  }
  </code></pre>
  
  <p>Also what exactly does return (n+addeven(n-1)) mean here?</p>