fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios_base::sync_with_stdio(0);
  6. cin.tie(0);
  7. cout.tie(0);
  8.  
  9. int n;
  10. cin >> n;
  11.  
  12. // Fibonacci ardıcıllığını hesablamaq üçün iki dəyişən
  13. long long a = 0, b = 1;
  14.  
  15. // Fibonacci ardıcıllığının n-ci elementini tapmaq
  16. for (int i = 2; i <= n; ++i) {
  17. long long next = a + b;
  18. a = b;
  19. b = next;
  20. }
  21.  
  22. // İlk iki element üçün xüsusi hal
  23. if (n == 1) cout << 0 << "\n";
  24. else if (n == 2) cout << 1 << "\n";
  25. else cout << b << "\n";
  26.  
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
4609061770539504808