title: Print triangle of numbers in java
body: <p>I've been having some trouble with a homework assignment for my Java class. In it, we're supposed to take in an integer between 1 and 13 and display three different triangles consisting of numbers. For example, if I were to enter 5, the result would be:</p>
  
  <p>Triangle 1</p>
  
  <pre><code>     1
       2  3
       4  5  6
       7  8  9 10
      11 12 13 14 15
  </code></pre>
  
  <p>Triangle 2</p>
  
  <pre><code>    1
      2 6
      3 7 10
      4 8 11 13
      5 9 12 14 15
  </code></pre>
  
  <p>Triangle 3</p>
  
  <pre><code>               5
              4  9
           3  8 12
        2  7 11 14
      1 6 10 13 15
  </code></pre>
  
  <p>I've already got the first Triangle going fine, but my big concern is the second triangle. I haven't attempted the third one yet. The other thing is that my Professor is picky about what method we use in creating the project. In other words, we can only use what he has taught us. He told us to use the System.out.printf("%3d", n) statement to space out the characters and we have to create them within a separate class.</p>
  
  <p>The code for the first triangle is as follows:</p>
  
  <pre><code>    void triangle1(int n)
      {
          int k = 1;
          for (int i = 1; i &lt;= n; i++)
          {
              for (int j = 0; j &lt; 1; j++)
              {
                  System.out.printf("%3d", n);
                  k += 1;
              }
  
              System.out.println();
          }
      }
  </code></pre>
  
  <p>So, pretty much, I need to follow that standard to create the other two triangles, but I'm really stuck on the second one and I don't know where to start. Any help will be much appreciated!</p>