Algorithm optimization

We should stop the search of factors when the candidate is greater than
the square root of the integer.