输出第n位斐波那契数列
知识点: List动态数组使用
class Program
{
static void Main(string[] args)
{
List<int> a = new List<int>();
int n = 10;
for(int i = 0; i < n; i++)
{
if(i == 0)
{
a.Add(0);
}
else if (i == 1)
{
a.Add(1);
}
else
{
a.Add(a[i - 1] + a[i - 2]);
}
}
Console.WriteLine(a.LastOrDefault());
Console.ReadLine();
}
}