fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. long int fib(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.  
  15. int main() {
  16. cout << fib(32) << endl;
  17. cout << fib(40) << endl;
  18. cout << fib(46) << endl;
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout
2178309
102334155
1836311903