forked from idg10/prog-cs-8-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
33 lines (30 loc) · 657 Bytes
/
Copy pathProgram.cs
File metadata and controls
33 lines (30 loc) · 657 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{
static IEnumerable<BigInteger> Fibonacci()
{
BigInteger n1 = 1;
BigInteger n2 = 1;
yield return n1;
while (true)
{
yield return n2;
BigInteger t = n1 + n2;
n1 = n2;
n2 = t;
}
}
static void Main(string[] args)
{
var evenFib = from n in Fibonacci()
where n % 2 == 0
select n;
foreach (BigInteger n in evenFib)
{
Console.WriteLine(n);
}
}
}