From bee55f635b31b53beeb7a90ec048c126b17386b2 Mon Sep 17 00:00:00 2001 From: worthant Date: Tue, 15 Oct 2024 04:33:38 +0300 Subject: [PATCH] :hammer: feat(lib): Simple task 9 implementation in python --- lib/task9/simple.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 lib/task9/simple.py diff --git a/lib/task9/simple.py b/lib/task9/simple.py new file mode 100644 index 0000000..fb1a760 --- /dev/null +++ b/lib/task9/simple.py @@ -0,0 +1,11 @@ +def find_pyth_triplet(sum_): + for a in range(1, sum_): + for b in range(1, sum_): + c = 1000 - a - b + if a**2 + b**2 == c**2: + return a, b, c + + +a, b, c = find_pyth_triplet(1000) +print(f"Pythagorean triplet: a = {a}. b = {b}, c = {c}") +print(f"Product abc = {a * b * c}")