Advertisement
LEGEND2004

Fibonacci

Jun 8th, 2024
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #pragma GCC optimize("O3")
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. //
  5. #define int long long
  6. #define double long double
  7. #define endl '\n'
  8. #define fastio ios_base::sync_with_stdio(0); cin.tie(0)
  9.  
  10. signed main()
  11. {
  12.     fastio;
  13.  
  14.     // evvelki 2 ededin cemi 0 1 ile baslayir bezen 1 1 ile baslayir kimi deyilir meselede
  15.     /*
  16.     // n ci fibo ededi tapmaq
  17.     int n;
  18.     cin >> n;
  19.     int f[n + 5];
  20.     f[0] = 0;
  21.     f[1] = 1;
  22.     for(int i = 2; i <= n; i++){
  23.         f[i] = f[i - 1] + f[i - 2];
  24.     }
  25.     cout << f[n] << '\n';
  26.     */
  27.     /*
  28.     // necenci fibo ededidi?
  29.     int n;
  30.     cin >> n;
  31.     int f[105];
  32.     f[0] = 1;
  33.     f[1] = 1;
  34.     for(int i = 2; i <= 90; i++){ // ededler tez tez artir 90 dan o terefe long longdan cox olur
  35.         f[i] = f[i - 1] + f[i - 2];
  36.         if(f[i] == n){
  37.             cout << i << '\n';
  38.             return 0;
  39.         }
  40.     }
  41.     cout << -1; // fibo ededi deyilse
  42.     */
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement