Created
May 5, 2013 19:56
-
-
Save maciejczyzewski/5521981 to your computer and use it in GitHub Desktop.
I-th term of the Fibonacci sequence
This file contains 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; | |
unsigned int fib(unsigned int n) { | |
if(n == 0) return 0; | |
if(n == 1) return 1; | |
return fib(n-1)+fib(n-2); | |
} | |
int main(){ | |
int n = 0; | |
cin >> n; | |
cout << fib(n) << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment