Sujet : Re: Relatively prime integers in NumPy
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.pythonDate : 11. Jul 2024, 23:43:47
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v6pjmj$2kqvg$3@dont-email.me>
References : 1 2 3 4
User-Agent : Pan/0.158 (Avdiivka; )
On Thu, 11 Jul 2024 11:35:44 -0700, Paul Rubin wrote:
Two numbers a and b are coprime if math.gcd(a,b) == 1, I am pretty sure.
That is true by definition(?) when a and b are both > 0. Experiment
indicates it seems to work even when one or both of a and b are
negative, but I don't have a proof and haven't examined the
implementation. I don't know how gcd is mathematically defined in that
situation.
You can derive the answer quite trivially by observing that negative
numbers are smaller (less than, not greater than) positive numbers.