|
|
От: | Kluev | |
| Дата: | 27.03.06 17:28 | ||
| Оценка: |
|
||
E>template< int N >
E>struct Factorial {
E> enum { value = N * Factorial< N-1 >::value };
E>};
E>template<>
E>struct Factorial< 0 > {
E> enum { value = 1 };
E>};
extern const double precomputed_factorials[];
inline double factorial(int n)
{
if ( n < precomp_factorial_max ) // берем готовый из таблицы
return precomputed_factorials[n];
// вычисляем по необходимости
}