Skip to content

Instantly share code, notes, and snippets.

@kaipakartik
Created January 10, 2014 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaipakartik/8345454 to your computer and use it in GitHub Desktop.
Save kaipakartik/8345454 to your computer and use it in GitHub Desktop.
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.
def special():
for a in xrange(1, 1001):
for b in xrange(1, 1001):
c = 1000 -a -b;
if c < 0:
break;
if a * a + b * b == c * c:
return a*b*c
print special()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment