title: How to reverse a string of numbers in a nested loop
body: <p>This is a homework question so I would like help, not an answer.</p>
  
  <p>I'm trying to create 2 triangles out of numbers based on a number entered by the user.</p>
  
  <pre><code>"Enter a number between 2-9: "3"
  1
  12
  123
  
    1
   21
  321
  </code></pre>
  
  <p>IE2:</p>
  
  <pre><code>"Enter a number between 2-9: "5"
  1
  12
  123
  1234
  12345
  
      1
     21
    321
   4321
  54321
  </code></pre>
  
  <p>I have been able to get the first triangle complete. But when I add my nested loop it messes up my first triangle with the numbers developed from the nested loop. It also puts all the numbers in a straight vertical line. I've tried variations for different nest loops and even tried messing with a <code>StringBuilder</code>, but was still unsuccessful.
  Here's what I have in code so far:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class NestedLoops
  {
      public static void main(String[] args)
      {
          Scanner input = new Scanner(System.in);
  
          System.out.print("Enter a Number between 2-9: ");
          int width = input.nextInt();
  
          String r = "";
          for (int i = 1; i &lt;= width; i++)
          {
              r = r + i;
              System.out.println(r);
  
          }
  
      }
  
  }
  </code></pre>
  
  <p>Again, I'm looking for help/understanding and not just an answer.</p>