1def basic_fermat(n): 2 a = ceil(sqrt(n)) 3 b2 = a^2 - n 4 while not is_square(b2): 5 a += 1 6 b2 = a^2 - n 7 return (a-sqrt(b2), a+sqrt(b2)) 8 9