fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. auto fib = [a = 0, b = 1]() mutable
  6. {
  7. auto res = b;
  8. auto tmp = a;
  9. a = b;
  10. b += tmp;
  11. return res;
  12. };
  13.  
  14. int main() {
  15. std::vector<int> v(100);
  16. for (auto i: v)
  17. {
  18. cout << fib() << ' ';
  19. }
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 4536KB
stdin
Standard input is empty
stdout
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 39088169 63245986 102334155 165580141 267914296 433494437 701408733 1134903170 1836311903 -1323752223 512559680 -811192543 -298632863 -1109825406 -1408458269 1776683621 368225352 2144908973 -1781832971 363076002 -1418756969 -1055680967 1820529360 764848393 -1709589543 -944741150 1640636603 695895453 -1958435240 -1262539787 1073992269 -188547518 885444751 696897233 1582341984 -2015728079 -433386095 1845853122 1412467027 -1036647147 375819880 -660827267 -285007387 -945834654 -1230842041 2118290601 887448560 -1289228135 -401779575 -1691007710 -2092787285 511172301 -1581614984 -1070442683 1642909629 572466946 -2079590721 -1507123775 708252800 -798870975 -90618175 -889489150 -980107325