Permalink
Browse files

fix(?) a bug in factor_lehman

  • Loading branch information...
1 parent e520083 commit c76b9a229e13ceeb88a146c60592c4242df4412e @fredrik-johansson fredrik-johansson committed Jun 29, 2012
Showing with 10 additions and 1 deletion.
  1. +1 −1 ulong_extras/factor_lehman.c
  2. +9 −0 ulong_extras/test/t-factor_lehman.c
@@ -58,7 +58,7 @@ mp_limb_t n_factor_lehman(mp_limb_t n)
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 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;
for ( ; x <= end; x++)
@@ -78,6 +78,15 @@ int main(void)
n1 = n_nextprime(n1, 1);
n2 = n_nextprime(n2, 1);
+ /* test a specific bug */
+#if FLINT64
+ if (i == 0)
+ {
+ n1 = 72528697;
+ n2 = 73339073;
+ }
+#endif
+
n = n1*n2;
n3 = n_factor_lehman(n);

0 comments on commit c76b9a2

Please sign in to comment.