]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
factor: use primes_diff more consistently
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 8 Jun 2025 07:59:44 +0000 (00:59 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 10 Jul 2025 00:12:39 +0000 (17:12 -0700)
* src/factor.c (mp_factor_using_division): Use index into
primes_diff consistently with other uses.  This is mostly just a
style change, and likely doesn’t change the generated machine code.

src/factor.c

index 8e52f0f50babf36391a90d981b032bd1e2d50669..52209eb7e8a9b83d2e484660780d20de2c6e0ada 100644 (file)
@@ -908,7 +908,7 @@ mp_factor_using_division (mpz_t t, struct mp_factors *factors)
     }
 
   unsigned long int d = 3;
-  for (idx_t i = 1; i <= PRIMES_PTAB_ENTRIES;)
+  for (idx_t i = 0; i < PRIMES_PTAB_ENTRIES; i++)
     {
       for (m = 0; mpz_divisible_ui_p (t, d); m++)
         {
@@ -921,7 +921,7 @@ mp_factor_using_division (mpz_t t, struct mp_factors *factors)
         }
       if (m)
         mp_factor_insert_ui (factors, d, m);
-      d += primes_diff[i++];
+      d += primes_diff[i + 1];
       if (mpz_cmp_ui (t, d * d) < 0)
         break;
     }