We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6417c1f + 1b4a6df commit 937b393Copy full SHA for 937b393
Mathematics/fibonacci/cpp/fibonacciUsingRecursion.cpp
@@ -0,0 +1,26 @@
1
+/*
2
+Problem Statement:
3
+Find nth term in fibonacci series using recursion
4
+*/
5
+
6
+#include<bits/stdc++.h>
7
+using namespace std;
8
9
+int fibonacci(int n) {
10
11
+ //base case
12
+ if (n == 0 or n == 1) {
13
+ return n;
14
+ }
15
16
+ return (fibonacci(n - 1) + fibonacci(n - 2));
17
+}
18
19
20
+int main() {
21
22
+ int n; cin >> n;
23
+ cout << fibonacci(n);
24
25
+ return 0;
26
0 commit comments