题目描述
一数列的规则如下:1、1、2、3、5、8、13、21、34......。求第n位数是多少?
输入
输入一个正整数,代表求第几位数字
输出
输出第n位数字
样例输入
copy
30
样例输出
832040
提示
输入数字必须大于零
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int m =int.Parse(Console.ReadLine());
int n = wahh(m);
Console.Write(n);
Console.ReadKey();
}
static int wahh(int n)
{
if (n <= 0)
return 0;
else if (n == 1)
return 1;
else
return wahh(n - 1) + wahh(n - 2);
}
}
}