Skip to content

Commit

Permalink
Merge pull request #1347 from priyalbhatewara123/dev
Browse files Browse the repository at this point in the history
Find nth term in fibonacci series using recursion
  • Loading branch information
i-vishi authored Oct 7, 2020
2 parents 6417c1f + 1b4a6df commit 937b393
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 937b393

Please sign in to comment.