I was trying for 2 for loops but it didn’t work
Expected Output
1
22
3
4444
5
666666
7
88888888
>Solution :
try this:
for (int i = 1; i <= 8; i++) {
if (i % 2 != 0) {
System.out.print(i + " ");
}
else {
for (int j = 1; j <= i; j++) {
System.out.print(i);
}
System.out.print(" ");
}
}