Help me in solving SYNJMCQ39 problem

My doubt was that wont the loop continue to print all the integers from 1 to infinity except the number ‘4’ which does not satisfy the given condition?

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

no it won’t run infinite as it gets 4 the loop will terminate.