Last active
July 1, 2019 17:28
-
-
Save manojnaidu619/770c590515e2c3127ca8be803a02a238 to your computer and use it in GitHub Desktop.
Fibonacci using Recursion in CPP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int fib(int n){ | |
if(n<=1){return n;}else{ | |
return fib(n-2) + fib(n-1); | |
} | |
} | |
int main(){ | |
int n = 0; | |
cout << fib(n) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment