C# 递归算法求 1,1,2,3,5,8,13···
static void Main(string[] args)
{
int[] cSum = new int[10];
for (int i = 0; i < cSum.Length; i++)
{
cSum[i] = Pro_WriteNum(i);
Console.WriteLine(cSum[i]);
}
Console.ReadLine();
}
private static int Pro_WriteNum(int a)
{
int result = 0;
if (a == 0 || a == 1)
{
result = 1;
}
else
result = Pro_WriteNum(a - 1) + Pro_WriteNum(a - 2);
return result;
}