Skip to content

Instantly share code, notes, and snippets.

@leonmaia
Created January 28, 2014 14:08
Show Gist options
  • Save leonmaia/8668315 to your computer and use it in GitHub Desktop.
Save leonmaia/8668315 to your computer and use it in GitHub Desktop.
Yield
public object Solve()
{
return Fibonnaci().Where(i => i % 2 == 0).Sum();
}
private static IEnumerable<int> Fibonnaci()
{
int a = 1,
b = 2;
yield return a;
yield return b;
while (b < 4000000)
{
var auxiliar = b;
b += a;
a = auxiliar;
yield return b;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment