fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7. int a = 0, b = 1, c = 1;
  8. while (n) {
  9. if (n > 1) {
  10. c = a + b;
  11. a = b;
  12. b = c;
  13. }
  14. --n;
  15. }
  16. cout << c;
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5276KB
stdin
3
stdout
2