function output = gcd(a, b)

    r = mod(a, b);
    if r > 0
        output = gcd(b, r);
    else
        output = b;
    end

end