MCPcopy Create free account
hub / github.com/chaharnishant11/CodeIn10DSA / Solution

Class Solution

Recursion/Homework/fibonacci.cpp:4–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2using namespace std;
3
4class Solution {
5 public:
6 long long int nthFibonacci(long long int n){
7 // code here
8
9 // Base Case
10 if (n == 0) {
11 return 0;
12 }
13
14 if (n == 1){
15 return 1;
16 }
17
18 // Recursive Call
19 long long int recCall1 = nthFibonacci(n-1);
20 long long int recCall2 = nthFibonacci(n-2);
21
22 // Small Calculation
23 long long int smallCal = recCall1 + recCall2;
24
25 return smallCal;
26
27 }
28};
29
30int main() {
31 int t;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected