int i =14; int j =2; for(i--;i>j;j+=2,i-=j%3){ System.out.println(i + " "); }

It returns 13,12,12,10 but I don’t understand the reason behind it!

## Answer

You should get familiar with the for loop First part initates the counter of the for loop normaly. Second part defines the condition to enter the loop for another round, third part updates the counter for the next round.

Starting the for loop i is set to 13 by i–.

- 13 is greater than 2.
- Therefore print i = 13.
- Update counters j = 4 by j+=2 and i= 12 by i-=4%3 alias i-=1.

Condition 12 is greater than 4 passed.

- Therefore print i = 12.
- Update counters j = 6 by j+=2 and i= 12 by i-=6%3 alias i-=0

Condition 12 is greater than 6 passed.

- Therefore print i = 12.
- Update counters j = 8 by j+=2 and i= 10 by i-=8%3 alias i-=2

Condition 10 is greater than 8 passed.

- Therefore print i = 10.
- Update counters j = 10 by j+=2 and i= 9 by i-=10%3 alias i-=1

Condition 9 is greater than 10 failed.

- Exit the loop.