Fibonacci

Run Settings
LanguageC#
Language Version
Run Command
using System; using System.Collections.Generic; using System.Linq; public static class Fibonacci { public static IEnumerable<ulong> Enumerate() { var mem = new ulong[] { 1, 0 }; for (byte b = 0; ; b ^= 1) yield return mem[b] += mem[1 - b]; } public static ulong ValueAt(int n) => Enumerate().Skip(n - 1).First(); } class MainClass { static void Main() { //any number over n = 93 is too big for ulong; therefore, I use BigInteger in .NET Framework //I should implement my own BigInteger here, but I'm just too lazy for now ;) var n = 1; foreach(var value in Fibonacci.Enumerate().Take(93)) Console.WriteLine($"{n++}: {value}"); } }
Editor Settings
Theme
Key bindings
Full width
Lines