-module(ef5).
-export([gcd/2]).

%tail-recursive definition of gcd

gcd(A,A) -> A;
gcd(A,B) -> {X,Y} = dummy(A,B),
            gcd(X-Y,Y).
            
dummy(A,B) -> if
                  A > B -> {A,B};
                  true  -> {B,A}
              end.            

dummy(X) -> X.


