Only need to go up to square root of end