gcd(a, b):  

    while 0 < b:
        r ← a % b   # a 除以 b 的余数
        a ← b
        b ← r

    return a