namespace RecursiveMethod
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("please input your number...");
int va = int.Parse(Console.ReadLine());
Console.WriteLine(Foo(va));
}
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);
}
}
}
}
Wednesday, October 8, 2008
Subscribe to:
Post Comments (Atom)


No comments:
Post a Comment