30 lines
464 B
Python
30 lines
464 B
Python
def div(sq, sub, quo):
|
|
return (sq ** 0.5 + sub) / quo
|
|
|
|
|
|
def cor(x):
|
|
a = 0
|
|
b = 1
|
|
v = 0
|
|
out = []
|
|
ab = []
|
|
while 1:
|
|
v = int(div(x, a, b))
|
|
tmp = b * v - a
|
|
b = (x - tmp ** 2) / b
|
|
a = tmp
|
|
ab.append((a,b))
|
|
out.append(v)
|
|
num = ab.index((a,b)) + 1
|
|
if num != len(ab):
|
|
return (out[:num], out[num:])
|
|
|
|
|
|
|
|
total = 0
|
|
for i in xrange(2, 10001):
|
|
if int(i ** 0.5) ** 2 != i:
|
|
if len(cor(i)[1]) % 2:
|
|
total += 1
|
|
print tota
|