public class testing
{
public void show() {
int num = 0;
int n = 5;
for (int i=1; i<n; i++) {
for (int j=0; j<i; j++) {
System.out.print(num++);
System.out.print(" ");
}
System.out.println(" ");
}
}
}
This question came up in one of our previous exams and I don't understand it. The answer is
0
1 2
3 4 5
6 7 8 9
But I have no clue how they got it. I kind of understand the 2nd to 4th line but have no clue how they got 0 on the first line. Any explanation would be highly appreciated, thanks!