Skip to content

Instantly share code, notes, and snippets.

@simonask
Created March 5, 2009 20:22
Show Gist options
  • Save simonask/74540 to your computer and use it in GitHub Desktop.
Save simonask/74540 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
template <int N> int fib() {
return fib<N-1>() + fib<N-2>();
}
template <>
int fib<0>() {
return 0;
}
template <>
int fib<1>() {
return 1;
}
int main (int argc, char const *argv[])
{
cout << fib<13>() << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment