Advertisement
Josif_tepe

Untitled

Mar 18th, 2021
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8.     int n;
  9.     cin >> n;
  10.     int fib[n + 1];
  11.     fib[1] = 1;
  12.     fib[2] = 1;
  13.     for(int i = 3; i <= n; i++) {
  14.         fib[i] = fib[i - 1] + fib[i - 2];
  15.     }
  16.     cout << fib[n] << endl;
  17.     return 0;
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement