GCD in standard library?
Erik Max Francis
max at alcyone.com
Thu Mar 13 02:45:11 CET 2003
Blake Garretson wrote:
> I'm just guessing it is very common
> for people to have to add this to their programs:
> def gcd(x,y):
> if x % y == 0: return y
> else: return gcd(y,x%y)
I would hope you'd use the iterative form. Function calls are
expensive, and can't recurse to arbitrary depths.
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ Life is an effort that deserves a better cause.
\__/ Karl Kraus
The laws list / http://www.alcyone.com/max/physics/laws/
Laws, rules, principles, effects, paradoxes, etc. in physics.
More information about the Python-list