Skip to content

Commit

Permalink
fix(?) a bug in factor_lehman
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrik-johansson committed Jun 29, 2012
1 parent e520083 commit c76b9a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ulong_extras/factor_lehman.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ mp_limb_t n_factor_lehman(mp_limb_t n)
for (k = 1; k <= cuberoot + 1; k++) for (k = 1; k <= cuberoot + 1; k++)
{ {
mp_limb_t x = (mp_limb_t) ceil(2.0*sqrt((double) k)*sqrt((double) n)); mp_limb_t x = (mp_limb_t) ceil(2.0*sqrt((double) k)*sqrt((double) n));
mp_limb_t end = x + (mp_limb_t) floor(1.0 + pow(n, 1.0/6.0)/((double) 4.0*sqrt((double) k))); mp_limb_t end = x + (mp_limb_t) floor(1.0 + pow(n, 1.0/6.0)/((double) 4.0*sqrt((double) k))) + 1;
mp_limb_t sub = k*n*4; mp_limb_t sub = k*n*4;


for ( ; x <= end; x++) for ( ; x <= end; x++)
Expand Down
9 changes: 9 additions & 0 deletions ulong_extras/test/t-factor_lehman.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ int main(void)
n1 = n_nextprime(n1, 1); n1 = n_nextprime(n1, 1);
n2 = n_nextprime(n2, 1); n2 = n_nextprime(n2, 1);


/* test a specific bug */
#if FLINT64
if (i == 0)
{
n1 = 72528697;
n2 = 73339073;
}
#endif

n = n1*n2; n = n1*n2;


n3 = n_factor_lehman(n); n3 = n_factor_lehman(n);
Expand Down

0 comments on commit c76b9a2

Please sign in to comment.