On Fri, Dec 12, 2003 at 12:42:10AM +0900, Robert Klemme wrote:
> def gcd2(a,b)
>   raise ArgumentError, "Value out of range" if a <= 0 || b <= 0
>   a,b = b,a if b > a
>   begin
>     a,b = b,a % b
>   end while b != 0
>   a
> end
Hi

A few remarks about the above - it's late, and i am tired, so forgive me if
I am wrong.. ;-=

.) Since b,a % b = b,a for b > a, you don't need the a,b-swapping I believe:
	gdc2(4,6) -> a=4,b=6
	a,b = b,a%b -> a=6,b=4%6=4
	So the swapping happens automagically.
.) Mathematically speaking, gdc is well-defined for negative arguments too..

So I would write it:
def gcd2(a,b)
	a,b=b,a%b while (b != 0)
	a.abs
end

greetings, Florian Pflug