fork(1) download
  1.  
  2. class Ideone
  3. {
  4. public static void main (String[] args) throws java.lang.Exception
  5. {
  6. int n=8,i,j,k,t;
  7. for (i=n;i>=1;i--)
  8. {
  9. t=i;
  10. for(j=1;j<i;j++)
  11. System.out.printf("%3c",32); // for leading spaces
  12. System.out.printf("%3d",i); // for first digit(or number) in each row (in your example these are 4,3,2,1)
  13. for(k=n;j<n;j++,k--)
  14. {
  15. t+=k;
  16. System.out.printf("%3d",t);
  17. }
  18. System.out.print("\n");
  19. }
  20. }
  21. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
                       8
                    7 15
                 6 14 21
              5 13 20 26
           4 12 19 25 30
        3 11 18 24 29 33
     2 10 17 23 28 32 35
  1  9 16 22 27 31 34 36