Skip to content

Instantly share code, notes, and snippets.

@Sohail05
Created April 30, 2018 02:46
Show Gist options
  • Save Sohail05/2a4390637141fc8cebd4b4b0c194d50d to your computer and use it in GitHub Desktop.
Save Sohail05/2a4390637141fc8cebd4b4b0c194d50d to your computer and use it in GitHub Desktop.
Fibonacci
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