fork download
  1. #include <iostream>
  2.  
  3. template<unsigned long long T>
  4. struct myFunc {
  5. enum moo : unsigned long long {
  6. value = myFunc<T-2>::value + myFunc<T-1>::value
  7. };
  8. };
  9.  
  10. template<>
  11. struct myFunc<2> {
  12. enum moo : unsigned long long {
  13. value = 1
  14. };
  15. };
  16.  
  17. template<>
  18. struct myFunc<1> {
  19. enum moo : unsigned long long {
  20. value = 1
  21. };
  22. };
  23.  
  24. template<>
  25. struct myFunc<0> {
  26. enum moo : unsigned long long {
  27. value = 0
  28. };
  29. };
  30.  
  31. template<unsigned long long i>
  32. struct fibonacci {
  33. static void loop() {
  34. std::cout << myFunc<i>::value << "\n";
  35. fibonacci<i-1>::loop();
  36. }
  37. };
  38.  
  39. template<>
  40. struct fibonacci<0> {
  41. static void loop() {
  42. std::cout << myFunc<0>::value << "\n";
  43. }
  44. };
  45.  
  46. int main() {
  47. fibonacci<92>::loop();
  48. }
Success #stdin #stdout 0s 2888KB
stdin
Standard input is empty
stdout
7540113804746346429
4660046610375530309
2880067194370816120
1779979416004714189
1100087778366101931
679891637638612258
420196140727489673
259695496911122585
160500643816367088
99194853094755497
61305790721611591
37889062373143906
23416728348467685
14472334024676221
8944394323791464
5527939700884757
3416454622906707
2111485077978050
1304969544928657
806515533049393
498454011879264
308061521170129
190392490709135
117669030460994
72723460248141
44945570212853
27777890035288
17167680177565
10610209857723
6557470319842
4052739537881
2504730781961
1548008755920
956722026041
591286729879
365435296162
225851433717
139583862445
86267571272
53316291173
32951280099
20365011074
12586269025
7778742049
4807526976
2971215073
1836311903
1134903170
701408733
433494437
267914296
165580141
102334155
63245986
39088169
24157817
14930352
9227465
5702887
3524578
2178309
1346269
832040
514229
317811
196418
121393
75025
46368
28657
17711
10946
6765
4181
2584
1597
987
610
377
233
144
89
55
34
21
13
8
5
3
2
1
1
0