Answer the question
In order to leave comments, you need to log in
Prolog. How to multiply two numbers by recursion?
I found this code, which seems to solve the problem, but when it is called, an error is generated. Perhaps I'm not calling it correctly? I hope for your help.
add(0,X,X).
add(s(X),Y,Z):-add(X,s(Y),Z).
mult(0,X,0).
mult(s(X),Y,Z):-mult(X,Y,A), add(Y,A,Z).
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question