fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, i = 2, f1 = 0, f2 = 1, cur;
  6. cin >> n;
  7.  
  8. while (i <= n)
  9. {
  10. cur = f1 + f2;
  11. f1 = f2;
  12. f2 = cur;
  13. i++;
  14. }
  15. if (n<=1)
  16. cout<<n;
  17. else
  18. cout << cur;
  19. return 0;
  20. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Standard output is empty