Skip to content

Instantly share code, notes, and snippets.

@Isweet
Last active August 29, 2015 14:06
Show Gist options
  • Save Isweet/5e47f06cf634f5c93908 to your computer and use it in GitHub Desktop.
Save Isweet/5e47f06cf634f5c93908 to your computer and use it in GitHub Desktop.
Generator for all pythagorean triples s.t. r < bound
# Generator for all pythagorean triples s.t. r < bound
def pyth_triples(bound):
for r in range(2, bound):
for s in range(1, r):
yield [r*r - s*s, 2*r*s, r*r + s*s]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment