[ create a new paste ] login | about

Link: http://codepad.org/LaZszEhR    [ raw code | output | fork ]

nilukush - C++, pasted on May 22:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>

template<long N>
class Fact
{   public:
        enum { result = N * Fact<N - 1>::result };
};

template<>
class Fact<0>
{   public:
        enum { result = 1 };
};

int main()
{   std::cout << Fact<10>::result;
    return 0;
}


Output:
1
3628800


Create a new paste based on this one


Comments: