1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
template <long n> struct Factorial { static const long value = n*Factorial<n-1>::value; }; template <> struct Factorial<0> { static const long value = 1; }; int main() { return Factorial<5>::value; }