factorial optimization suggested by pponywong.
This commit is contained in:
parent
52b3bc9437
commit
6a6b3edce1
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user