Skip to content

Instantly share code, notes, and snippets.

@mvirkkunen
Last active August 29, 2015 14:00
Show Gist options
  • Save mvirkkunen/11178217 to your computer and use it in GitHub Desktop.
Save mvirkkunen/11178217 to your computer and use it in GitHub Desktop.
// http://bartoszmilewski.com/2014/04/21/getting-lazy-with-c/ except that in C#. Still a bit fugly.
Enumerable.Range(1, Int32.MaxValue)
.SelectMany(z => Enumerable.Range(1, z - 1)
.SelectMany(x => Enumerable.Range(x, z - x)
.Where(y => x*x + y*y == z*z)
.Select(y => Tuple.Create(x, y, z))))
.Take(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment