1st time ... x = 2 and i = 2
2nd time ...x=4 and i=3
3rd time.....x=16 and i = 4
4th time ......before entering the loop value of x < 1000 ....it is 16 so it will enter the loop
and make i = 5
5th time x>1000 so while loop doesn't execute.....
SO the answer is i = 5