-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheuler9.py
More file actions
34 lines (26 loc) · 746 Bytes
/
Copy patheuler9.py
File metadata and controls
34 lines (26 loc) · 746 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
#!/usr/bin/env python
"""
Euler Problem 9 solved: 190424
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a**2 + b**2 = c**2
For example, 32 + 42 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
"""
# a in range (1, 995)
# b in range (2, 996)
# c in range (3, 997)
# a ** 2 + b ** 2 == c**2
# a + b + c == 1000
# a < b < class
total = 1000
at = total - 5
bt = total - 4
ct = total - 3
for a in range (1, at+1):
for b in range (2, bt+1):
for c in range (3, ct+1):
if(a < b < c and a**2 + b**2 == c**2 and a + b + c == total):
print(">>> "+str(a) + ", " + str(b) + ", "+ str(c))
print (a * b * c)
#answer: 31875000