From 51e8456e9be682fe4dd526185bc4c955fb179ad9 Mon Sep 17 00:00:00 2001 From: Lauchmelder23 Date: Tue, 9 Oct 2018 21:58:45 +0200 Subject: [PATCH] Added Problem 9 --- Problem_9.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Problem_9.py diff --git a/Problem_9.py b/Problem_9.py new file mode 100644 index 0000000..2f534da --- /dev/null +++ b/Problem_9.py @@ -0,0 +1,21 @@ +###################################################################### +# A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, +# +# a² + b² = c² +# For example, 3² + 4² = 9 + 16 = 25 = 5². +# +# There exists exactly one Pythagorean triplet for which a + b + c = 1000. +# Find the product abc. +# +###################################################################### + +for a in range(1, 1000): + for b in range(1, 1000 - a): + c = 1000 - a - b + + if pow(a, 2) + pow(b, 2) == pow(c, 2): + print(a*b*c) + exit() + + +# Solution: 31875000