この階乗の実装が機能しない理由:
factorial(0, B) :- B is 1.
factorial(A, B) :-
A > 0,
Ax is A-1,
B is A*Bx,
factorial(Ax, Bx).
そしてこれは機能します:
factorial2(0, B) :- B is 1.
factorial2(A, B) :-
A > 0,
Ax is A-1,
factorial2(Ax, Bx),
B is A*Bx.