You can do this with a nested loop:
public static void main(String[] args){
for(int i=5, i>0, i--){
for(int j=i, j>0; j--)
System.out.print(i);
System.out.print(' ');
}
}
The outer loop decrements the integer that you are printing and the inner loop will print the integer the number of times equal to its value.
Copyright © 2026 eLLeNow.com All Rights Reserved.