using System.Collections.Generic;
using static System.Console;
public static void Main()
WriteLine(Fibonacci(10));
var range = Enumerable.Range(1, 10);
var evens = Filter(range, (x) => x % 2 == 0);
WriteLine(String.Join("; ", evens));
public static int Fibonacci(int x)
if (x < 0) throw new ArgumentException("Less negativity please!", nameof(x));
(int current, int previous) Fib(int i)
if (i == 0) return (1, 0);
var (p, pp) = Fib(i - 1);
public static IEnumerable<T> Filter<T>(IEnumerable<T> source, Func<T, bool> filter)
if (source == null) throw new ArgumentNullException(nameof(source));
if (filter == null) throw new ArgumentNullException(nameof(filter));
IEnumerable<T> Iterator()
foreach (var element in source)
if (filter(element)) { yield return element; }