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.


CARD FUNC Gcd(CARD a,b)
  CARD tmp
 
  IF a<b THEN
    tmp=a a=b b=tmp
  FI
 
  WHILE b#0
  DO
    tmp=a MOD b
    a=b 
    b=tmp
  OD
RETURN(a)
 
PROC Test(CARD a,b)
  CARD res
 
  res=Gcd(a,b)
  PrintF("GCD of %I and %I is %I%E",a,b,res)
RETURN
 
PROC Main()
  Test(48,18)
  Test(9360,12240)
  Test(17,19)
  Test(123,1)
  Test(0,0)
RETURN