fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. long long n;
  6.  
  7. int main()
  8. {
  9. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  10.  
  11. cin >> n;
  12. long long x = 0, y = 1; // x = f[i - 2], y = f[i - 1]
  13. for (int i = 2; i <= n; i++)
  14. {
  15. long long next_i = x + y;
  16. x = y;
  17. y = next_i;
  18. }
  19. cout << y;
  20. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
1