fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. int main()
  5. {
  6. double phi = (1 + std::sqrt(5))/2;
  7. for(int n = 1; n <= 20; ++n) {
  8. unsigned int fib = std::pow(phi, n)/sqrt(5) + 0.5;
  9. std::cout << fib << '\n';
  10. }
  11. }
  12.  
Success #stdin #stdout 0s 2852KB
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