using System;
namespace 斐波那契
{
class Program
{
static void Main(string[] args)
{
UInt32 n;
Console.WriteLine("輸入求結果的個數值:");
n = Convert.ToUInt32(Console.ReadLine());
if (n == 1)
{
Console.WriteLine("第一個數爲1");//第一個數沒有不符合以下算法
}
else
{
int i, a = 0, b = 1, result = 1;
for (i = 1; i < n; i++)//只有小於才能正確實現
{
result = a + b;
a = b;
b = result;
}
Console.WriteLine("第{0}個數爲{1}", n, result);
}
Console.ReadKey();
}
}
}