Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 218
Image: ubuntu2004
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 %d\n", x - st + 1) return(x + y) print("No factors found in %d \n", rounds)
FermatAttack(next_prime(1178900875984375493875975943857489375948375498375948375943875)*next_prime(1178900875984375493875975943857489375948375498375948375943876),10000)
('No factors found in %d \n', 10000)