I'm currently working through Project Euler, and this was my attempt (in Python) at problem 3. I ran this and let it for roughly 30 minutes. After this, I looked at the numbers under "sum". I found several issues: some of these numbers were even, and thus not prime, and some of these numbers weren't even proper factors of n. Granted, they were only off by 0.000001 (usually division yielded x.99999230984 or whatever). The number I eventually stopped at was 3145819243.0.
Can anyone explain why these errors occur?
EDIT: My interpretation of the theorem was basically that, with rearranging of variables, you could solve for x with the square root of n + y^2, and y would be bruteforced until it was an integer. After this, the actual prime factor would be x+y.
Here is my code.
import math
n = int(600851475143)
y = int(1)
while y >= 1:
if math.sqrt(n + (y**2)).is_integer():
x = math.sqrt(n + (y**2))
print "x"
print x
print "sum"
print x + y
if x + y > (600851475142/2):
print "dead"
else:
print "nvm"
y = y + 1