From: Mathieu Bouchard Date: 2001-08-05T01:46:09+09:00 Subject: [ruby-talk:19145] Re: Endianness and integer indexing On Sat, 4 Aug 2001, Eric Lee Green wrote: > # Find the gcd of two numbers, self and i, using the > # Euclidean algorithm. Seems to work fairly fast! > def gcd(i) > n=self.clone > if n >= i > a=n > b=i.clone > else > a=i.clone > b=n > end > while b > 0 > r = a % b > a = b.clone > b= r.clone > end > return a > end I don't know why you are doing #clone at all. It doesn't slow down so much though (it just returns self, even for Bignum). Try this: def gcd(i) if self>=i then a,b=self,i else a,b=i,self end while b>0 do a,b=b,a%b end a end matju