Skip to content

Instantly share code, notes, and snippets.

@thieux
Last active May 24, 2017 12:24
Show Gist options
  • Save thieux/fb81c135c54198ba0ca61999360280be to your computer and use it in GitHub Desktop.
Save thieux/fb81c135c54198ba0ca61999360280be to your computer and use it in GitHub Desktop.
A brute force approach to generate pythagorean triples in Python 3
MAX = 100
pythagorean_triples = [(a, b, c) for a in range(2, MAX) for b in range(2, MAX) for c in range(2, MAX) if a*a + b*b == c*c]
print(pythagorean_triples)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment