Mercurial > octave
changeset 31524:8027b17bcb92
maint: Merge stable to default.
author | Arun Giridhar <arungiridhar@gmail.com> |
---|---|
date | Wed, 23 Nov 2022 08:59:59 -0500 |
parents | bbd07d0f587b (current diff) 88d2395500e7 (diff) |
children | 7b6d4b6afef2 |
files | |
diffstat | 1 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/__isprimelarge__.cc Wed Nov 23 05:23:12 2022 -0500 +++ b/libinterp/corefcn/__isprimelarge__.cc Wed Nov 23 08:59:59 2022 -0500 @@ -213,12 +213,12 @@ // factorization algorithm with Brent update. // The code is short and simple, but the math behind it is complicated. uint64_t -pollardrho (uint64_t n, uint64_t c = UINT64_C (1)) +pollardrho (uint64_t n, uint64_t c = 1) { - uint64_t i = UINT64_C (1), j = UINT64_C (2); // cycle index values - uint64_t x = (c+1) % n; // can also be rand () % n - uint64_t y = x; // other value in the chain - uint64_t g = 0; // GCD + uint64_t i = 1, j = 2; // cycle index values + uint64_t x = (c+1) % n; // can also be rand () % n + uint64_t y = x; // other value in the chain + uint64_t g = 0; // GCD while (true) { @@ -238,10 +238,10 @@ j <<= 1; } - if (g == n || i > UINT64_C (1000000)) // cut losses, restart with a different c + if (g == n || i > 1000000) // cut losses, restart with a different c return pollardrho (n, c + 2); - if (g > UINT64_C (1)) // found GCD ==> exit loop properly + if (g > 1) // found GCD ==> exit loop properly { error_unless (n % g == 0); // theoretical possibility of GCD error return g;