Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- int fib[n + 1];
- fib[1] = 1;
- fib[2] = 1;
- for(int i = 3; i <= n; i++) {
- fib[i] = fib[i - 1] + fib[i - 2];
- }
- cout << fib[n] << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement