Skip to content

Instantly share code, notes, and snippets.

@SajjadArifGul
Created October 9, 2015 13:16
Show Gist options
  • Save SajjadArifGul/d1502027dc26680bd0ad to your computer and use it in GitHub Desktop.
Save SajjadArifGul/d1502027dc26680bd0ad to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace fibonacci
{
class fibo
{
public int fibonacci(int value)
{
if (value == 0)
{
return 0;
}
else if (value == 1)
{
return 1;
}
else
{
return fibonacci(value - 1) + fibonacci(value - 2);
}
}
}
class Program
{
static void Main(string[] args)
{
fibo f = new fibo();
Console.WriteLine("Enter element number?");
int element = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(f.fibonacci(element));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment