Niels Möller nisse at
Tue Sep 3 08:05:08 UTC 2019

Seth Troisi <braintwo at> writes:

> Trying to sum up the proposals for how this api should work,
> 1. add mpz_prevprime(rop, op) or mpz_precprime(rop, op)
> 2. change mpz_nextprime(-10) => -7 (instead of 2)
> 3. add mpz_nextprime_seq(a, b) => next prime a + k*b with k >= 1
> Considerations
> 1. on negative number return X?
> Should prevprime return "input had correct sign"? should nextprime?
> 2. this is an incompatible change for the interface (but probably not one
> many people depenedend on)
> 3. a bigger change than other two proposals.
> ---
> Personally I'm a fan of number 1. because I can clearly see the steps
> needed.

To me, 1 seems like a good improvement. It can be generalized to 3
later. For return value, I'd prefer

int mpz_prevprime(mpz_ptr p, mpz_srcptr n);

with return value 0, and p unchanged, if there is no (positive) prime <
n, otherwise 1, or possibly 2 for definitely, rather than probably,

And I think it's too unconventional to include negatives in the set of
prime numbers.


Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.

More information about the gmp-devel mailing list