7. Write Prolog program to implement multi (N1, N2, R) : where N1 and N2 denotes the numbers to be multiplied and R represents the result.
% Write Prolog program to implement multi (N1, N2, R) : where N1 and N2 denotes the
numbers to be multiplied and R represents the result.
% below m function is not predefined you can use any name as function
m(N,1,N).
m(N,M,A):-
T is M-1,
m(N,T,Y),
A is Y+N.
% Output
No comments:
Post a Comment