|
| 1 | +diff --git a/src/basemath/ifactor1.c b/src/basemath/ifactor1.c |
| 2 | +index 526ac5c1b3..5fb4454353 100644 |
| 3 | +--- a/src/basemath/ifactor1.c |
| 4 | ++++ b/src/basemath/ifactor1.c |
| 5 | +@@ -3595,7 +3595,7 @@ ifactor_sign(GEN n, ulong all, long hint, long sn, GEN *pU) |
| 6 | + { |
| 7 | + GEN M, N; |
| 8 | + pari_sp av; |
| 9 | +- long nb = 0, nb0 = 0, i; |
| 10 | ++ long nb = 0, nb0 = -1, i; |
| 11 | + ulong lim; |
| 12 | + forprime_t T; |
| 13 | + |
| 14 | +@@ -3666,7 +3666,7 @@ ifactor_sign(GEN n, ulong all, long hint, long sn, GEN *pU) |
| 15 | + affii(n, N); n = N; set_avma(av3); |
| 16 | + STOREu(&nb, p, k); |
| 17 | + } |
| 18 | +- if (p == 16381 && bit_accuracy(lgefint(n)) < 2048) |
| 19 | ++ if (!stop && p == 16381 && bit_accuracy(lgefint(n)) < 2048) |
| 20 | + { stop = ifac_isprime(n); nb0 = nb; } |
| 21 | + if (stop) |
| 22 | + { |
| 23 | +@@ -3706,15 +3706,14 @@ ifactor_sign(GEN n, ulong all, long hint, long sn, GEN *pU) |
| 24 | + long k; |
| 25 | + av = avma; |
| 26 | + k = isanypower_nosmalldiv(n, &x); |
| 27 | +- if (k > 1) affii(x, n); |
| 28 | ++ if (k > 1) { affii(x, n); nb0 = -1; } |
| 29 | + if (pU) |
| 30 | + { |
| 31 | + GEN F; |
| 32 | + if (abscmpiu(n, lim) <= 0 |
| 33 | + || cmpii(n, sqru(lim)) <= 0 |
| 34 | + || (all >= (1<<14) |
| 35 | +- && (nb > nb0 || k > 1) |
| 36 | +- && bit_accuracy(lgefint(n)) < 2048 && ifac_isprime(n))) |
| 37 | ++ && nb > nb0 && bit_accuracy(lgefint(n)) < 2048 && ifac_isprime(n))) |
| 38 | + { set_avma(av); STOREi(&nb, n, k); return aux_end(M,n, nb); } |
| 39 | + set_avma(av); F = aux_end(M, NULL, nb); /* don't destroy n */ |
| 40 | + *pU = mkvec2(icopy(n), utoipos(k)); /* composite cofactor */ |
0 commit comments