Monday, 31 October 2016

Write a Prolog program to implement GCD of two numbers.

% Write a Prolog program to implement GCD of two numbers.

/* GCD of two numbers. */
gcd(X,0,X).
gcd(X,Y,Z):- 
 R is mod(X,Y),
 gcd(Y,R,Z).

% Output
Write a Prolog program to implement GCD of two numbers.
Write a Prolog program to implement GCD of two numbers.

1 comment: