fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. long int fib2(int n){
  5. int a = 1;
  6. int b = 1;
  7. for (int i = 3; i <= n; i++){
  8. int pom = a;
  9. a = b;
  10. b = pom + b;
  11. }
  12. return b;
  13. }
  14. int main( ) {
  15. cout << fib2(32) << endl;
  16. cout << fib2(40) << endl;
  17. cout << fib2(46) << endl;
  18. return 0;
  19. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
2178309
102334155
1836311903