Fibonacci series in C# using recursion

The Fibonacci sequence is a series of numbers where the next number is the addition of the last two numbers, The Fibonacci series starts with 0, and 1.

For example, fibonacci series are: 0 1 1 2 3 5 8 13

program for fibonacci series in c# using recursion

In this program, you will take the length of Fibonacci series and find Fibonacci series using recursion

using System;
class Fibonacci {
    public int recursive_fibs(int a)
    {
        if (a==0) return 0;
        else if(a==1)
            return 1;
        else
            return (recursive_fibs(a-1) + recursive_fibs(a-2));
    }
  public static void Main() {
      int i,n,ans;
      Console.Write("Enter the length of series:");
      n=int.Parse(Console.ReadLine());
      Fibonacci fib = new Fibonacci(); // Creating Object 
      for(i=0;i<n;i++)
      {	
        ans=fib.recursive_fibs(i);
        Console.Write(ans+"\t"); 
      }
    }
}

output

Enter the length of series:8
0       1       1       2       3       5       8       13