如果目标可以(5,3)输出可能是5,4,3这个我的代码发现了大错误
predicates
count(integer, integer)
clauses
count(X, Y) :- X > Y, write(3), !.
count(X < Y) :- X > Y, write(X), nl, X1 = X-1, count(X1, Y).
答案 0 :(得分:2)
count(X,X):-write(X),nl.
count(X,Y):-X<Y,write(X),nl,X1 is X+1,count(X1,Y).