Created
July 13, 2011 02:51
-
-
Save copenhas/1079622 to your computer and use it in GitHub Desktop.
example.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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