Skip to content

Instantly share code, notes, and snippets.

@yhstvhd
Last active July 24, 2021 08:34
Show Gist options
  • Save yhstvhd/a43c8dd077478a674c631b6c166c19e7 to your computer and use it in GitHub Desktop.
Save yhstvhd/a43c8dd077478a674c631b6c166c19e7 to your computer and use it in GitHub Desktop.
フィボナッチ数列を再帰で
using System;
namespace Fibonacci
{
class Program
{
//フィボナッチ数列を再帰処理
static void Main(string[] args)
{
int x = 10;
Console.WriteLine(Fibonacci(10));
}
public static int Fibonacci(int x)
{
if (x < 2)
return x;
else
return Fibonacci(x - 1) + Fibonacci(x - 2);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment