using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 30; i++)
{
Console.Write(Foo(i)+"\t");
}
}
public static int Foo(int i)
{
if (i<0)
{
return 0;
}else if(i>0 && i < 2)
{
return 1;
}
else
{
return Foo(i - 1) + Foo(i - 2);
}
}
}
}
效果如下: