fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5.  
  6. int main() {
  7.  
  8. int n, a=1, b=1, c;
  9. cin >> n;
  10.  
  11. if (n==1 || n==2)
  12. cout << 1 << endl;
  13. else
  14. {
  15. for(int i=3; i<=n; i++)
  16. {
  17. c=a+b;
  18. a=b;
  19. b=c;
  20. }
  21. cout << c << endl;
  22. }
  23.  
  24.  
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 5316KB
stdin
2
stdout
1