-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem510.py
More file actions
40 lines (35 loc) · 757 Bytes
/
Copy pathproblem510.py
File metadata and controls
40 lines (35 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import mylib, math
L = 10 ** 9
r = math.floor(L ** 0.5)
s = 0
pp = tuple(x + 1 for x in range(r))
dd = dict()
ff = dict()
for q in pp:
for p in pp:
if p > q:
break
t = p * q / (p + q)
if not t % 1:
t = round(t)
a = p ** 2
b = q ** 2
c = t ** 2
d = (a, b, c)
f = b / a
print("\033[F\033[K", d, f)
if f not in ff:
print()
ff[f] = True
dd[d] = True
print("\033[F\033[K")
# print(dd)
# print(ff)
print("summation\n")
for d in dd:
x = L // d[1]
m = x * (x + 1) // 2
print("\033[F\033[K", d, "x", x, " xx ", m)
s += sum(d) * m
print("\033[F\033[K")
print(s)