Created
October 9, 2015 13:16
-
-
Save SajjadArifGul/d1502027dc26680bd0ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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