Advertisement
kalabukdima

Fibonacci C++14

Dec 10th, 2020 (edited)
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <memory>
  3. #include <vector>
  4.  
  5. constexpr int Fib(int n) {
  6.     int a = 1;
  7.     int b = 1;
  8.     for (int i = 0; i < n; ++i) {
  9.         int t = a + b;
  10.         a = b;
  11.         b = t;
  12.     }
  13.     return b;
  14. }
  15.  
  16. template <class>
  17. struct TD;
  18.  
  19. int main() {
  20.     std::array<int, Fib(10)> a;
  21.     TD<decltype(a)> t;
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement