fibonacci in C# : Method Recursion : Class C# Examples


C# Examples » Class » Method Recursion »

 

fibonacci in C#









    
using  System;
using  System.Collections.Generic;
using  System.Reflection;
using  System.Runtime.InteropServices;

public  class  MainClass
{
      public  static  void  Main(){
            Console.WriteLine(Fibonacci(10));
      }
        static  int  Fibonacci(int  x)
        {
                if  (x  <=  1)
                        return  1;
                return  Fibonacci(x  -  1)  +  Fibonacci(x  -  2);
        }
}
    
   
  
   



Output

89


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Class
» Method Recursion