title: Recursively splitting off perfect squares for display
body: <p>I am attempting to create a recursive method that accepts an integer parameter and prints the first <em>n</em> squares
  separated by commas, with the odd squares in descending order followed by the even squares in ascending order.</p>
  
  <p>For example, if the input is 8, it should print the following output:</p>
  
  <pre><code>49, 25, 9, 1, 4, 16, 36, 64
  </code></pre>
  
  <p>My code so far is:</p>
  
  <p><code>s</code> and <code>n</code> have the same values initially, the only difference is that s changes as the code forwards while <code>n</code> doesn't change.</p>
  
  <pre><code>private static void genSquare(int s, int n) {
      if (s &gt;= 0 &amp;&amp; s &lt;= n) {
          if (isOdd(s)) {
              System.out.print(Math.pow(n, 2) + " ");
              genSquare(s - 2, n);
          }
          if (s == 0 || s == 1) {
              genSquare(1, n);
          }
          if (isEven(s)) {
              System.out.print(Math.pow(n, 2) + " ");
              genSquare(s + 2, n);
          }
      }
  }
  </code></pre>
  
  <p>I have created a while loop version of it, which works perfectly.  I just don't have the recursive version working.</p>
  
  <p>Sample inputs would be using the same number for s and n.</p>
  
  <p>Here is the code for the loop version:</p>
  
  <pre><code>private void genLoop(int s, int n) {
      if (isEven(s)) {
          s--;
      }
  
      while (s &lt;= n) {
          if (s == 1) {
              System.out.print(1 + "  ");
              s++;
          } else if (isOdd(s)) {
              System.out.print(s * s + "  ");
              s -= 2;
          } else if (isEven(s)) {
              System.out.print(s * s + "  ");
              s += 2;
          }
      }
  }
  </code></pre>