-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9_Special_Pythagorean_triplet.py
More file actions
53 lines (52 loc) · 1.06 KB
/
9_Special_Pythagorean_triplet.py
File metadata and controls
53 lines (52 loc) · 1.06 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
# A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
#
# a**2 + b**2 = c**2
# For example, 3**2 + 4**2 = 9 + 16 = 25 = 5**2.
#
# There exists exactly one Pythagorean triplet for which a + b + c = 1000.
# Find the product abc.
# Tembelce bir çözüm oldu :)
a = 3
b = 4
c = 5
while True:
while a + b + c < 1000:
a += 3
b += 4
c += 5
if a + b + c == 1000:
print(a * b * c)
break
else:
a = 5
b = 12
c = 13
while a + b + c < 1000:
a += 5
b += 12
c += 13
if a + b + c == 1000:
print(a * b * c)
break
else:
a = 8
b = 15
c = 17
while a + b + c < 1000:
a += 8
b += 15
c += 17
if a + b + c == 1000:
print(a * b * c)
break
else:
a = 7
b = 24
c = 25
while a + b + c < 1000:
a += 7
b += 24
c += 25
if a + b + c == 1000:
print(a * b * c)
break