fibonacci series using recursion
snippet in c

fibonacci series using recursion

user4411

//Fibonacci Series using Recursion 
#include<stdio.h> 
int fib(int n) 
{ 
   if (n <= 1) 
      return n; 
   return fib(n-1) + fib(n-2); 
} 
  
int main () 
{ 
  int n = 9; 
  printf("%d", fib(n)); 
  getchar(); 
  return 0; 
} 

fibonacci series using recursion

user2173

//Fibonacci Series using Recursion 
#include<bits/stdc++.h> 
using namespace std; 
  
int fib(int n) 
{ 
    if (n <= 1) 
        return n; 
    return fib(n-1) + fib(n-2); 
} 
  
int main () 
{ 
    int n = 9; 
    cout << fib(n); 
    getchar(); 
    return 0; 
} 
  
// This code is contributed 
// by Akanksha Rai 

fibonacci series using recursion

user4628

# Function for nth Fibonacci number 
  
def Fibonacci(n): 
    if n<0: 
        print("Incorrect input") 
    # First Fibonacci number is 0 
    elif n==0: 
        return 0
    # Second Fibonacci number is 1 
    elif n==1: 
        return 1
    else: 
        return Fibonacci(n-1)+Fibonacci(n-2) 
  
# Driver Program 
  
print(Fibonacci(9)) 
  
#This code is contributed by Saket Modi 

fibonacci series using recursion

user574

//Fibonacci Series using Recursion 
class fibonacci 
{ 
    static int fib(int n) 
    { 
    if (n <= 1) 
       return n; 
    return fib(n-1) + fib(n-2); 
    } 
       
    public static void main (String args[]) 
    { 
    int n = 9; 
    System.out.println(fib(n)); 
    } 
} 
/* This code is contributed by Rajat Mishra */

fibonacci series using recursion

user4714

// C# program for Fibonacci Series  
// using Recursion 
using System;  
  
public class GFG  
{  
    public static int Fib(int n)  
    {  
        if (n <= 1)  
        {  
            return n;  
        }  
        else
        {  
            return Fib(n - 1) + Fib(n - 2);  
        }  
    }  
          
    // driver code 
    public static void Main(string[] args)  
    {  
        int n = 9; 
        Console.Write(Fib(n));  
    }  
}  
  
// This code is contributed by Sam007