Mercurial > octave
diff libinterp/corefcn/__isprimelarge__.cc @ 31051:5f015f2829b7
maint: Merge stable to default
author | Arun Giridhar <arungiridhar@gmail.com> |
---|---|
date | Wed, 01 Jun 2022 17:20:22 -0400 |
parents | b65e4c635343 3a93a77dd4cf |
children | 068342cc93b8 |
line wrap: on
line diff
--- a/libinterp/corefcn/__isprimelarge__.cc Tue May 31 23:34:23 2022 -0400 +++ b/libinterp/corefcn/__isprimelarge__.cc Wed Jun 01 17:20:22 2022 -0400 @@ -116,20 +116,12 @@ // If the number passes all 12 tests, then it is prime. // If it fails any, then it is composite. // The first 12 primes suffice to test all 64-bit integers. - if (! millerrabin ( 2, d, r, n)) return false; - if (! millerrabin ( 3, d, r, n)) return false; - if (! millerrabin ( 5, d, r, n)) return false; - if (! millerrabin ( 7, d, r, n)) return false; - if (! millerrabin (11, d, r, n)) return false; - if (! millerrabin (13, d, r, n)) return false; - if (! millerrabin (17, d, r, n)) return false; - if (! millerrabin (19, d, r, n)) return false; - if (! millerrabin (23, d, r, n)) return false; - if (! millerrabin (29, d, r, n)) return false; - if (! millerrabin (31, d, r, n)) return false; - if (! millerrabin (37, d, r, n)) return false; - // If we are all the way here, then it is prime. - return true; + return millerrabin ( 2, d, r, n) && millerrabin ( 3, d, r, n) + && millerrabin ( 5, d, r, n) && millerrabin ( 7, d, r, n) + && millerrabin (11, d, r, n) && millerrabin (13, d, r, n) + && millerrabin (17, d, r, n) && millerrabin (19, d, r, n) + && millerrabin (23, d, r, n) && millerrabin (29, d, r, n) + && millerrabin (31, d, r, n) && millerrabin (37, d, r, n); /* Mathematical references for the curious as to why we need only