Java: Displaying an odd number right-triangle made up of characters
<p>I have to write a program that takes a size value and turns it into a right triangle (made up of <code>#</code> characters) such that the output looks like:</p>

<pre><code>#

    #
  ###
#####

      #
    ###
  #####
#######
</code></pre>

<p>The first triangle is of size 1.
The second triangle is of size 4.
The third triangle is of size 6.
Notice that the the number of characters per each line in a given triangle is always odd. 
Also notice that the height of each triangle at the largest point can be calculated by <code>size/2 + 1</code></p>

<p>I have attempted this problem, but I am stuck figuring out how I can display the correct number of <code>#</code> symbols per line. </p>

<p>Here is my own code:</p>

<pre><code>public class triangle {

    public static void drawTriangle(int size) {
        int column = (size/2) + 1;

            for (int i = 0; i &lt;= column; i++) {
                for (int j = size; j &gt;= 0; j--) {
                    if (i &lt;= j) {
                        System.out.print(" ");
                    }
                    else {
                        System.out.print("#");
                    }
                }
                System.out.println();
            }
    }

    public static void main(String[] args) {
        drawTriangle(1);
        drawTriangle(4);
        drawTriangle(6);
    }
}
</code></pre>

<p>And here is the output from my code:</p>

<pre><code>#

    #
   ##
  ###

      #
     ##
    ###
   ####
</code></pre>

<p>As you can see I have arranged the triangles in the proper way, and have gotten the height of each triangle to be the way it supposed to. I just have no idea how I can get the correct number off characters on each line...</p>

<p>I have tried several things including changing my first for loop from:</p>

<pre><code>for (int i = 0; i &lt;= column; i++)
</code></pre>

<p>to </p>

<pre><code>for (int i = 1; i &lt;= column; i+=2)
</code></pre>

<p>Which filters out the even numbered rows, but fails to address the other parameters such as height of each triangle, and additional rows. Here is the output for my changes:</p>

<pre><code> #
    #
  ###
      #
    ###
</code></pre>

<p>Any help is appreciated, thanks.</p>