def isqrt(n):
return int(floor(sqrt(n)))
def usqrt (n):
ur = isqrt(n)
if ur ** 2 < n:
ur = ur + 1
return(ur)
def FermatAttack (n, rounds):
st = usqrt(n)
for x in range(st, st + rounds + 1):
sq = x ** 2 - n
y = isqrt(sq)
if y ** 2 == sq:
print("Factor found in round {0}".format( x - st + 1))
return(x + y)
print("No factors found in {0}".format( rounds))