Yes, it is more efficient as it requires fewer number of checks. We just check if third number is
integer? which obviously is far less costly than searching for a number, , that satisfies the constraint .
However, this comes with an assumption that the computation of
sqrt takes insignificant time comapared to scanning the numbers from to .