math/euclids_gcd/ruby/euclids_gcd.rb
# Function implementing Euclid's GCD Algorithm
Function implementing Euclid's GCD Algorithm
Function implementing Euclid ' s GCD Algorithm
def euclids_gcd (a = 1, b = 1)
	divisor = b
	dividend = a
	while (divisor != 0)
		remainder = dividend % divisor
		dividend = divisor
		divisor = remainder
	end
	gcd = dividend
	return gcd
end
def euclids_gcd ( a = 1 , b = 1 ) divisor = b dividend = a while ( divisor != 0 ) remainder = dividend % divisor dividend = divisor divisor = remainder end gcd = dividend return gcd end
Function implementing Euclid's GCD Algorithm
Function implementing Euclid ' s GCD Algorithm
######################################################################################################################### #The Euclidean Algorithm for finding GCD(A,B) is as follows: # If A = 0 then GCD(A,B)=B, since the GCD(0,B)=B, and we can stop.   # If B = 0 then GCD(A,B)=A, since the GCD(A,0)=A, and we can stop.   # Write A in quotient remainder form (A = B⋅Q + R) # Find GCD(B,R) using the Euclidean Algorithm since GCD(A,B) = GCD(B,R) #########################################################################################################################
a
<not_specific>
b
<not_specific>