title: recursive function
body: <p>I'm trying to write a recursive function which take an integer  ,n, and give all the even number to zero and then every number to n...</p>
  
  <p><em>this is what I have so far</em>   </p>
  
  <pre><code>def kaboom(n):
     if n&gt;=0:
       if n%2==0:
             print n,
             print kaboom(n-2),
       else:
             n=n-1
             print n,
             print kaboom(n-2),
     print n,    
     n=n+1
     return n
  </code></pre>
  
  <p><em>the output is</em></p>
  
  <p>kaboom(5)</p>
  
  <pre><code>4 2 0 None 0 1 2 3 4
  
  5
  </code></pre>
  
  <p>kaboom(4)</p>
  
  <pre><code>4 2 0 None 0 1 2 3 4
  </code></pre>
  
  <p>5</p>
  
  <p><strong>but it should be</strong></p>
  
  <p>kaboom(5)</p>
  
  <pre><code>4 2 0 1 2 3 4 5
  </code></pre>
  
  <p><em>and</em></p>
  
  <p>kaboom(4)</p>
  
  <pre><code>4 2 0 1 2 3 4
  </code></pre>
  
  <p>and by the way this is not homework :)</p>