#------------------------------------------------------
#$Author: saulius $
#$Date: 2009-11-09 19:07:25 +0500 (Mon, 09 Nov 2009) $ 
#$Revision: 573 $
#$Id: GCD.pm 573 2009-11-09 14:07:25Z saulius $
#------------------------------------------------------
#*
#  Euclid's GCD (Greatest Common Divisor) algorithm.
#**
package GCD;
use strict;
use warnings;
use Carp::Assert;

sub gcd($$)
{
    my ($x, $y) = @_;
    assert( $x > 0 );
    assert( $y > 0 );
    while( $x != $y ) {
        if( $x > $y ) {
            $x -= $y;
        } else {
            $y -= $x;
        }
    }
    return $x;
}
1;
