Calculates the greatest common divisor of two numbers. Attention: pipes in the substitution separate alternatives. If one alternative does not match, the next alternative is tried if it exists. The substitution must be repeated until it cannot substitute further.