29 lines
512 B
Python

import time
def is_sqrt(x, y):
z = x ** 2 + y ** 2
if int(z ** 0.5) ** 2 == z:
if x > y:
return x // 2 - x + y + 1
else:
return x // 2
return 0
def count(m):
count = 0
for a in range(1, m * 2 + 1):
count += is_sqrt(a, m)
return count
def gen(limit):
m = 1
tale = 0
while tale < limit:
tale += count(m)
m += 1
return m - 1, tale
print(gen(1000000))
print(time.process_time())