title: 54321 4321 321 1 in Java
body: <p>Hi everyone i need a java program to print:</p>
  
  <pre><code>54321
   4321
    321
     21
      1
  </code></pre>
  
  <p>I could get the numbers but am failing to understand how to space it like the above. Hope I could get some help. Thanks!</p>
  
  <pre><code>public class a
  {
     public static void main()
     {
      for(int x=5;x&gt;=1;x--)
      {
          for (int y=x;y&gt;0;y--)
          System.out.print(y);
          System.out.println();
      }
     }
  }
  </code></pre>
  
  <p><strong>EDIT</strong>:
  Thanks to @nickb i was able to get this.... 
  This was the code i used for right-aligned spacing, just in case people in future need it for reference:</p>
  
  <pre><code>for(int space=5-x;space&gt;0;space--)
  System.out.print(" ");
  </code></pre>