Skip to content

Instantly share code, notes, and snippets.

@maciejczyzewski
Created May 5, 2013 19:56
Show Gist options
  • Save maciejczyzewski/5521981 to your computer and use it in GitHub Desktop.
Save maciejczyzewski/5521981 to your computer and use it in GitHub Desktop.
I-th term of the Fibonacci sequence
#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