fork(1) download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. const double sqrt5 = sqrt(5);
  5. const double phi = (1 + sqrt(5)) / 2;
  6. const double xi = (1 - sqrt(5)) / 2;
  7.  
  8.  
  9. double fib(unsigned n){
  10. double eax = pow(phi, n);
  11. double ebx = pow(xi, n);
  12. return (eax - ebx) / sqrt5;
  13. }
  14.  
  15. int main(void) {
  16. int i;
  17. for(i = 0; i < 100; i++)
  18. printf("%.2f\n", fib(i));
  19. return 0;
  20. }
Success #stdin #stdout 0s 2156KB
stdin
Standard input is empty
stdout
0.00
1.00
1.00
2.00
3.00
5.00
8.00
13.00
21.00
34.00
55.00
89.00
144.00
233.00
377.00
610.00
987.00
1597.00
2584.00
4181.00
6765.00
10946.00
17711.00
28657.00
46368.00
75025.00
121393.00
196418.00
317811.00
514229.00
832040.00
1346269.00
2178309.00
3524578.00
5702887.00
9227465.00
14930352.00
24157817.00
39088169.00
63245986.00
102334155.00
165580141.00
267914296.00
433494437.00
701408733.00
1134903170.00
1836311903.00
2971215073.00
4807526976.00
7778742049.00
12586269025.00
20365011074.00
32951280099.00
53316291173.00
86267571272.00
139583862445.00
225851433717.00
365435296162.00
591286729879.00
956722026041.00
1548008755920.00
2504730781961.00
4052739537881.01
6557470319842.01
10610209857723.02
17167680177565.04
27777890035288.06
44945570212853.09
72723460248141.17
117669030460994.27
190392490709135.44
308061521170129.69
498454011879265.19
806515533049395.00
1304969544928660.00
2111485077978055.25
3416454622906715.50
5527939700884771.00
8944394323791488.00
14472334024676260.00
23416728348467744.00
37889062373144008.00
61305790721611752.00
99194853094755776.00
160500643816367552.00
259695496911123328.00
420196140727490880.00
679891637638614272.00
1100087778366105088.00
1779979416004719360.00
2880067194370824704.00
4660046610375544832.00
7540113804746369024.00
12200160415121913856.00
19740274219868282880.00
31940434634990198784.00
51680708854858489856.00
83621143489848688640.00
135301852344707186688.00
218922995834555891712.00