85263d45-3918-4d6f-89fd-fe09f754bcdc
prompter
Write me a program in C++ to compute the factorial of a number at compile time, using only C++03
4bf3f398-39bb-46d0-9a6a-fee4b8d93de8
85263d45-3918-4d6f-89fd-fe09f754bcdc
assistant
Here is a a C++ program that computes a factorial at compile time, that is compliant with the C++03 standard.

```cpp
template<unsigned int N>
unsigned int fac() {
    return fac<N-1>() * N;
};

template<>
unsigned int fac<0>() {
    return 1;
}
```

Using templates and template specialization we define a function fac<N>() which returns fac<N-1>()*N, specializing the case where N = 0 to return 1.
8f195eee-a8ce-4eb5-8d7f-72810448bc4b
4bf3f398-39bb-46d0-9a6a-fee4b8d93de8
prompter
That is a bit too complicated for my liking. I think adding some comments could make this better understandable.