Problem 4
My solution.
Optimization

Added an iteration counter
Added a lower bound when we try to find a divisor