title: Recursive algorithm for the sum of odd number positive integers
body: <p>I am expressing the algorithms in pseudo code. I'm just wondering if my design works just as well as the original one displayed below. The algorithm is supposed to compute the sum of n odd positive integers.</p>
  
  <p>This is how the algorithm should look:</p>
  
  <pre><code> procedure sumofodds(n:positive integer)
      if n = 1
         return 1
      else
         return sumofodds(n-1) + (2n-1)
  </code></pre>
  
  <p>This is how i designed my algorithm:</p>
  
  <pre><code>procedure odd(n: positive integer)
      if n = 1
         return 1
      if n % 2 &gt; 0
         return n + odd(n-1)    // this means n is odd
      if n % 2 = 0
         return 0 + odd(n-1)    // this means its even
  </code></pre>