Skip to content

Instantly share code, notes, and snippets.

@njlr
Last active May 31, 2017 15:35
Show Gist options
  • Save njlr/57d8c29a8a972710fea8f118f95778cb to your computer and use it in GitHub Desktop.
Save njlr/57d8c29a8a972710fea8f118f95778cb to your computer and use it in GitHub Desktop.
template<unsigned n>
struct Fibonacci {
static const unsigned value = Fibonacci<n - 1>::value + Fibonacci<n - 2>::value;
};
template<>
struct Fibonacci<0> {
static const unsigned value = 0;
};
template<>
struct Fibonacci<1> {
static const unsigned value = 1;
};
int main() {
return Fibonacci<5>::value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment