Advertisement
LEGEND2004

C - Fibonacci

Aug 31st, 2023
725
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5.  
  6. int n;
  7. int f[50];
  8.  
  9. signed main()
  10. {
  11.     cin >> n;
  12.     f[0] = 1;
  13.     f[1] = 1;
  14.     for(int i = 2; i <= n; i++){
  15.         f[i] = f[i - 1] + f[i - 2];
  16.     }
  17.     cout << f[n] << endl;
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement