domains
A,B,C = symbol
N,P = integer
predicates
tower(integer,symbol,symbol,symbol,integer)
go
clauses
go :- clearwindow,
write("enter value of N (For Transfering from A To B)"),
readint(N),
tower(N,'a','b','c',N).
tower(N,A,B,C,P):-
N > 1,
P is N-1
tower(P,A,C,B,P),
write([move , A,B]),nl,
tower(P,C,B,A,P).
tower(0,_,_,_):- !.