Euclid's Algorithm in Python?
apardon at forel.vub.ac.be
Sun Aug 14 16:41:42 CEST 2005
On 2005-08-08, Bengt Richter <bokr at oz.net> wrote:
> On 7 Aug 2005 17:31:02 -0700, "Jordan Rastrick" <jrastrick at student.usyd.edu.au> wrote:
>>Good point. I suppose I'd only ever seen it implemented with the if
>>test, but you're right, the plain while loop should work fine. Silly
>> while b != 0:
>> a, b = b, a%b
>> return a
> what is the convention for handling signed arguments? E.g.,
As far as I understand the convention is it doesn't make
sense to talk about a gcd if not all numbers are positive.
I would be very interested if someone knows what the gcd
of 3 and -3 should/would be.
More information about the Python-list