def gcd(a,b):
    """Calculate the Greatest Common Divisor of a and b.
    e.g. 8 , 12 
    becomes 12, 8
    becomes 8, 4
    becomes 4, 0
    returns 4"""
    while b:
        a, b = b, a%b
    return a