Last active
December 24, 2015 03:39
-
-
Save aausch/6738368 to your computer and use it in GitHub Desktop.
http://projecteuler.net/problem=9
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2
For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2013, Alex Ausch | |
# Free to use under attribution license: http://creativecommons.org/licenses/by/2.0/ca/ | |
for b in range(1,500): | |
c = (- b ** 2 + 1000 * b - 500000)/(b-1000) | |
a = (c**2 - b**2)**0.5 | |
if (a+b+c) == 1000 and int(a) == a and a > 0: | |
print a,b,c | |
print a * b * c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment