Skip to content

Instantly share code, notes, and snippets.

@IneonInoodle
Created September 11, 2018 08:35
Show Gist options
  • Save IneonInoodle/584f926c350df249245438715b6f9875 to your computer and use it in GitHub Desktop.
Save IneonInoodle/584f926c350df249245438715b6f9875 to your computer and use it in GitHub Desktop.
static List<int> GenerateFibonacciNumbers(int n)
{
List<int> myList = new List<int>();
for (int i = 0, j = 0, k = 1; i < n; i++)
{
myList.Add(j);
int temp = j + k;
j = k;
k = temp;
}
return myList;
}
public static void Main(String[] args)
{
List<int> myOuterList = GenerateFibonacciNumbers(5);
foreach (int x in myOuterList)
{
Console.WriteLine(x);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment