% For all integers A, the gcd of A and 0 is A
gcd(A, 0, A).

% For all integers B, the gcd of 0 and B is B
gcd(0, B, B).

gcd(A, B, C) :- A >= B, D is A - B, gcd(D, B, C).
gcd(A, B, C) :- A < B, D is B - A, gcd(A, D, C).
