%program of tower of hanoi
predicates
hanoi(integer).
hanoi1(integer,symbol,symbol,symbol).
clauses
hanoi(P):-
hanoi1(P,"A","B","C").
hanoi1(0,R,S,T).
hanoi1(P,R,S,T):-
U=P-1,
hanoi1(U,R,T,S),
write("move disk no ",P," from ",R," to ",T),nl,
readchar(A),
hanoi1(U,S,R,T).
%output
%move disk no 1 from A to C
%move disk no 2 from A to B
%move disk no 1 from C to B
%move disk no 3 from A to C
%move disk no 1 from B to A
%move disk no 2 from B to C
%move disk no 1 from A to C