Sunday, February 16, 2025

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

 

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.

No comments:

Post a Comment

15. Write a Prolog program to implement two predicates evenlength(List) and oddlength(List) so that they are true if their argument is a list of even or odd length respectively.

  Write a Prolog program to implement two predicates evenlength(List) and oddlength(List) so that they are true if their argument is a list ...