factorial optimization suggested by pponywong.
This commit is contained in:
@ -11,8 +11,10 @@ namespace
|
|||||||
// Basic integer factorial.
|
// Basic integer factorial.
|
||||||
inline static int factorial( int v )
|
inline static int factorial( int v )
|
||||||
{
|
{
|
||||||
if (v == 0) {
|
const static int fac_table[] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800 };
|
||||||
return 1;
|
|
||||||
|
if(v <= 11){
|
||||||
|
return fac_table[v];
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = v;
|
int result = v;
|
||||||
|
Reference in New Issue
Block a user