參考答案:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CSD04
{
class Program
{
static void Main(string[] args)
{
int[] nums = new int[] { 1, 5, 7, 11, 50 };
// TODO: calculate the fibonacci number.
long[] fib = new long[100];
fib[0] = 0;
fib[1] = 1;
for (int i = 2; i < fib.Count(); i++)
{
fib[i] = fib[i - 1] + fib[i - 2];
}
for (int j = 0; j < nums.Count(); j++)
{
Console.WriteLine("Fibonacci Number at {0} is {1}",nums[j],fib[nums[j]]);
}
Console.ReadLine();
}
}
}
執行結果:
留言列表