Subject: | Factors() method checks up to n/2 instead of int(sqrt(n)) |
The trial division method algorithm of factors() checks numbers between
int(sqrt(n)) and n/2 for factors of n. For instance, instead of checking
up until 10 for factors of 100, it checks up to 50. This is wasted
computation. The if statement in XS.xs for factors() should read
something like
if( i > int(sqrt(number)) ) break;
Cheers,