Last active
August 29, 2015 14:07
-
-
Save VHarisop/f1a3081e1bdfba8f305f to your computer and use it in GitHub Desktop.
Pythagorean Triplets
This file contains 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
__author__ = 'VHarisop' | |
''' Pythagorean triplets are integers (a, b, c) for which the property | |
a^2 + b^2 = c^2 holds. ''' | |
from math import sqrt | |
print filter(lambda x: round(sqrt(x[2]))**2 == x[2], [(i, j, i**2 + j**2) for i in range(1, 501) for j in range(i+1, 501)]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment