// For gprolog on omega.uta.edu. // Include /usr/local/bin in your path. // These are entered under [user]. gcd2(A,A,A). gcd2(A,B,G) :- A>B, C is A-B, gcd2(C,B,G). gcd2(B,A,G) :- A>B, C is A-B, gcd2(C,B,G). // Queries for either version of prolog. gcd2(1870,1045,X). gcd2(210,231,X). // for http://ioctl.org/logic/prolog-latest // gtr and leq are in the wrong direction! gcd2(A, A, A). gcd2(A, B, G) :- gtr(B,A), sub(A,B,C), gcd2(C, B, G). gcd2(B, A, G) :- gtr(B,A), sub(A,B,C), gcd2(C, B, G).