夏天哥哥

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

  输出  1,1,2,3,5,8,13,...........

public static int Main(string[] args)
{
for (int j = 0; j <= 29; j++)
{
Console.WriteLine(sum(j));
}
Console.ReadKey();
return 0;
}
public static int sum(int n)
{
int result;

if (n < 2)
{
result
= 1;
}
else
{
result
= sum(n - 1) + sum(n - 2);
}
return result;
}

 

posted on 2010-11-15 12:47  夏天哥哥  阅读(209)  评论(0编辑  收藏  举报