Skip to content

Instantly share code, notes, and snippets.

@copenhas
Created July 13, 2011 02:51
Show Gist options
  • Save copenhas/1079622 to your computer and use it in GitHub Desktop.
Save copenhas/1079622 to your computer and use it in GitHub Desktop.
example.cs
public IEnumerable<int> Fibanocci() {
var x1 = 1;
var x2 = 1;
while(true) {
var x3 = x1 + x2;
x1 = x2;
x2 = x3;
yield return x3;
}
}
public static void Main() {
var sequence = Fibanocci();
foreach(var number in sequence.Take(5)) {
Console.PrintLine(number.ToString());
}
foreach(var number in sequence.Take(5)) {
Console.PrintLine(number.ToString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment