Advertisement
Fhernd

NonRecursiveFibonacci.cs

Jul 4th, 2016
1,017
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.43 KB | None | 0 0
  1. // List to store Fibonacci numbers:
  2. List<ulong> fibonacciNumbers = new List<ulong>();
  3.  
  4. // Generate Fibonacci numbers just summing up the
  5. // last previous fibonacci numbers
  6. Enumerable.Range(0, 200)
  7.     .ToList()
  8.     .ForEach(k =>
  9.         fibonacciNumbers.Add(k <= 1 ? 1:
  10.             fibonacciNumbers[k-2] + fibonacciNumbers[k-1]));
  11.  
  12. // Lists the first 53 Fibonacci numbers:
  13. fibonacciNumbers.Take(53).Dump("Fibonacci Numbers");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement