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. }
  13. return b;
  14.  
  15. }
  16. int main () {
  17. cout << fib2(32) << endl;
  18. cout << fib2(40) << endl;
  19. cout << fib2(46) << endl;
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
2178309
102334155
1836311903