Greatest common divisor

You are encouraged to solve this task according to the task description, using any language you may know.
Task

Find the greatest common divisor   (GCD)   of two integers.


Greatest common divisor   is also known as   greatest common factor (gcf)   and   greatest common measure.



Related task

   least common multiple.


See also

   MathWorld entry:   greatest common divisor.
   Wikipedia entry:     greatest common divisor.


HAI 1.3
 
HOW IZ I gcd YR a AN YR b
	a R BIGGR OF a AN PRODUKT OF a AN -1   BTW  absolute value of a
	b R BIGGR OF b AN PRODUKT OF b AN -1   BTW  absolute value of b
	BOTH SAEM a AN b, O RLY?
		YA RLY
			FOUND YR a
		OIC
	BOTH SAEM a AN 0, O RLY?
		YA RLY
			FOUND YR b
		OIC
	BOTH SAEM b AN 0, O RLY?
		YA RLY
			FOUND YR a
		OIC
	BOTH SAEM b AN BIGGR OF a AN b, O RLY?       BTW  make sure a is the larger of (a, b)
		YA RLY
			I HAS A temp ITZ a
			a R b
			b R temp
		OIC
 
	IM IN YR LOOP
		I HAS A temp ITZ b
		b R MOD OF a AN b
		a R temp
		BOTH SAEM b AN 0, O RLY?
			YA RLY
				FOUND YR a
			OIC
	IM OUTTA YR LOOP 
IF U SAY SO
 
VISIBLE I IZ gcd YR 40902 AN YR 24140 MKAY
 
KTHXBYE