Correctness, Invariants & Design



Select all that apply
Answer & solution
Answer: B: floor(√N)+1 (no official key was published)
For the non-strict the guard, the loop exits at the smallest integer i whose square exceeds N. That is floor(√N)+1, including a perfect square N=k², which returns k+1. For nonsquares both expressions coincide. For example, N=4 distinguishes 3 from 2. The source change therefore matters and is not a harmless formatting variation. This arithmetic analysis assumes i*i and the increment do not overflow the Pascal integer range.