Created
April 30, 2018 02:46
-
-
Save Sohail05/2a4390637141fc8cebd4b4b0c194d50d to your computer and use it in GitHub Desktop.
Fibonacci
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; | |
namespace Fibonacci | |
{ | |
class MainClass | |
{ | |
public static void Main (string[] args) | |
{ | |
Console.WriteLine ("================"); | |
Console.WriteLine ("Enter N Value"); | |
int N; | |
N = Convert.ToInt32(Console.ReadLine()); | |
Console.WriteLine("N = {0}", N); | |
int R; | |
R =Fib(N); | |
Console.WriteLine(R); | |
Console.ReadKey (true); | |
} | |
public static int Fib( int x ){ | |
if( x <= 1 ){ | |
return x; | |
} | |
else{ | |
return Fib (x - 1) + Fib (x - 2); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment