111,126
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Program pro = new Program();
int count = int.Parse(Console.ReadLine());
Console.WriteLine(pro.work(30));
Console.ReadKey();
}
//1,1,2,3,5,8,13...
//假设n=30
int work(int n)
{
if (n <= 2)
{
return 1;
}
else
{
return work(n - 1) + work(n - 2);
}
}
}
}
int A1=1, A2=1,A3=0;
for (int N = 3; N < 34; N++)
{
A3 = A1 + A2;
Console.WriteLine("第{0}位:{1}", N, A3);
A1 = A2;
A2 = A3;
}