I have written this code (in python) for factorize a integer in prime numbers (Fermat's theorem).
#!/usr/bin/python2
import random,math
n=590632926550117049
a=math.ceil(math.sqrt(n))
b2=a*a-n
while math.sqrt(b2)!=math.floor(math.sqrt(b2)):
a=a+1
b2=a*a-n
b=math.sqrt(b2)
p=a+b
q=a-b
print("p =",p)
print("q =",q)
The number n=590632926550117049 is the product of 57848543*10209987943 but my program returns: 1156469901*510720535. Why ?
EDIT: i.e. with 187 or 15 or another number works fine.