Skip to content

Instantly share code, notes, and snippets.

@VHarisop
Last active August 29, 2015 14:07
Show Gist options
  • Save VHarisop/f1a3081e1bdfba8f305f to your computer and use it in GitHub Desktop.
Save VHarisop/f1a3081e1bdfba8f305f to your computer and use it in GitHub Desktop.
Pythagorean Triplets
__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