Skip to content

Instantly share code, notes, and snippets.

@eiiches
Created March 26, 2012 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eiiches/2204302 to your computer and use it in GitHub Desktop.
Save eiiches/2204302 to your computer and use it in GitHub Desktop.
Fibonatti
#include <iostream>
template <int i>
struct fib {
static const int value = fib<i-1>::value + fib<i-2>::value;
};
template <>
struct fib<0> {
static const int value = 1;
};
template <>
struct fib<1> {
static const int value = 1;
};
int
main(int argc, char **argv)
{
std::cerr << fib<4>::value << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment