I need to write some java using 3 "for" loops that output
122333444455555
22333444455555
333444455555
444455555
55555
The code I have so far is:
public static void problemFour() {
for(int i = 5; i >= 1; i--) {
for(int a = 1; a <= i; a++) {
for(int b = 1; b <= a; b++) {
System.out.print(a);
}
}
System.out.println();
}
}
Displays
111112222333445
11111222233344
111112222333
111112222
11111
I have included many keyboard shortcuts ++ - 's, <s,>, 5 and 1.
I'm pretty stuck if someone could point me in the right direction, that would be fantastic.
source
share