fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. template<unsigned int N>
  6. class Factorial
  7. {
  8. public:
  9. static const int value = Factorial<N-1>::value*N;
  10. };
  11.  
  12. template<>
  13. class Factorial<0>
  14. {
  15. public:
  16. static const int value = 1;
  17. };
  18.  
  19.  
  20. int main()
  21. {
  22. cout << Factorial<5>::value << endl;
  23. }
  24.  
  25.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
120