22 lines
441 B
Python
22 lines
441 B
Python
|
|
'''(sqrt(num) + a) / b'''
|
|
|
|
def con_frac(num):
|
|
a, b = 0, 1
|
|
para = []
|
|
while b and (a, b) not in para:
|
|
d = int((num ** 0.5 + a) / b)
|
|
yield d
|
|
para.append((a, b))
|
|
a = b * d - a
|
|
b = (num - a ** 2) // b
|
|
|
|
def count(limit):
|
|
total = 0
|
|
for x in range(2, limit + 1):
|
|
if not len(list(con_frac(x))) % 2:
|
|
total += 1
|
|
return total
|
|
|
|
print(count(10000))
|