How do you write 55555 4444 333 22 1 in java?

Java

1 answer

Answer

1244285

2026-07-17 21:05

+ Follow

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.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.