%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Computes the minimum common multiple M of two numbers A and B
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:-consult_lib.
mcm(A,B,M) :-
MA = {X : exists(Z, Z in int(1,B) & X is A * Z)}! &
MB = {X : exists(Z, Z in int(1,A) & X is B * Z)}! &
xinters(MA,MB,MAB) &
min(MAB,M)!.
min(S,X) :-
X in S &
forall(Z in S, X =< Z).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Sample goal:
%
% {log}=> mcm(4,6,X).
% X = 12