factorial optimization suggested by pponywong.

This commit is contained in:
castano 2008-05-06 06:37:06 +00:00
parent 52b3bc9437
commit 6a6b3edce1

View File

@ -11,8 +11,10 @@ namespace
// Basic integer factorial.
inline static int factorial( int v )
{
if (v == 0) {
return 1;
const static int fac_table[] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800 };
if(v <= 11){
return fac_table[v];
}
int result = v;