Help me in solving SYNJMCQ40 problem

My issue

Learning course: Learn Java
Problem Link: CodeChef: Practical coding for everyone

see here while a=1 b is printed as 4
then b is increased by 1 , and the condision is given while a!=b so it will loop infinitely as b will increased every time and a will never catch b . the distance between a and b remains 3 as a constaint.