Challenge of the day " C++"

What will this program output ?
C++
#include <iostream>

template<int N>
struct Fibonacci {
static const int value = Fibonacci<N - 1>::value + Fibonacci<N - 2>::value;
};

template<>
struct Fibonacci<0> {
static const int value = 0;
};

template<>
struct Fibonacci<1> {
static const int value = 1;
};

int main() {
std::cout << Fibonacci<6>::value;
return 0;
}
C++
#include <iostream>

template<int N>
struct Fibonacci {
static const int value = Fibonacci<N - 1>::value + Fibonacci<N - 2>::value;
};

template<>
struct Fibonacci<0> {
static const int value = 0;
};

template<>
struct Fibonacci<1> {
static const int value = 1;
};

int main() {
std::cout << Fibonacci<6>::value;
return 0;
}
2 Replies
Manuel
Manuel•12mo ago
Two to the power of three. 😉
nour_oud
nour_oudOP•12mo ago
correct ✅
Want results from more Discord servers?
Add your server