Skip to content

Commit

Permalink
Find nth term in fibonacci series using recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
priyalbhatewara123 committed Oct 2, 2020
1 parent 96e6573 commit 1b4a6df
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Mathematics/fibonacci/cpp/fibonacciUsingRecursion.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Problem Statement:
Find nth term in fibonacci series using recursion
*/

#include<bits/stdc++.h>
using namespace std;

int fibonacci(int n) {

//base case
if (n == 0 or n == 1) {
return n;
}

return (fibonacci(n - 1) + fibonacci(n - 2));
}


int main() {

int n; cin >> n;
cout << fibonacci(n);

return 0;
}

0 comments on commit 1b4a6df

Please sign in to comment.