Algorithm-Test/数组连加/Program.cs

28 lines
541 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i <= 30; i++)
{
Console.WriteLine(getsum(i));
}
}
static int getsum(int n)
{
if (n < 2)
return 1;
else{
return getsum(n - 2) + getsum(n - 1);
}
}
}
}