anduin revidoval tento gist . Přejít na revizi
1 file changed, 25 insertions
Program.cs(vytvořil soubor)
@@ -0,0 +1,25 @@ | |||
1 | + | using System; | |
2 | + | using System.Collections.Generic; | |
3 | + | using System.Linq; | |
4 | + | ||
5 | + | public class Program | |
6 | + | { | |
7 | + | public static void Main() | |
8 | + | { | |
9 | + | foreach (var i in Fibonacci().Take(20)) | |
10 | + | { | |
11 | + | Console.WriteLine(i); | |
12 | + | } | |
13 | + | } | |
14 | + | ||
15 | + | private static IEnumerable<int> Fibonacci() | |
16 | + | { | |
17 | + | int current = 1, next = 1; | |
18 | + | ||
19 | + | while (true) | |
20 | + | { | |
21 | + | yield return current; | |
22 | + | next = current + (current = next); | |
23 | + | } | |
24 | + | } | |
25 | + | } |
Novější
Starší