Created
March 26, 2012 10:13
-
-
Save eiiches/2204302 to your computer and use it in GitHub Desktop.
Fibonatti
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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