moves(N,R) :-
N = 0, R is 0.
moves(N,R) :-
N = 1, R is 1.
moves(N,R) :-
N > 1, T1 is N - 1, T2 is N-1, moves(T1,R1), moves(T2,R2), R is R1 + R2 + 1.
我收到未捕获的异常:错误(exist_error(procedure,moves / 1),top_level / 0)
当我尝试运行此查询和提示将有所帮助谢谢!
移动(7)。返回上面的错误
答案 0 :(得分:0)
试试这个:
moves(0,0).
moves(1,1).
moves(N,R) :-
N > 1, T1 is N-1, moves(T1,R1), moves(T1,R2), R is R1 + R2 + 1.