Skip to content

Instantly share code, notes, and snippets.

@vasily-kirichenko
Created August 28, 2011 08:39
Show Gist options
  • Select an option

  • Save vasily-kirichenko/1176433 to your computer and use it in GitHub Desktop.

Select an option

Save vasily-kirichenko/1176433 to your computer and use it in GitHub Desktop.
C# fibonacci
static void Main()
{
foreach (var i in Enumerable.Range(0, 39))
Console.WriteLine("n={0} => {1}", i, fib(i));
}
static int fib(int n)
{
if (n == 0 || n == 1)
return n;
return fib(n - 1) + fib(n - 2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment