% move(1, A, B, _Aux) :- % write("Move the top disk from "), % write(A), write(" to "), write(B). % T(1) = 1 move(1, A, B, _Aux) :- format("Move the top disk from ~w to ~w.~n", [A, B]). % T(N) = T(N - 1) + T(1) + T(N - 1) = 2*T(N- 1) + 1 move(N, A, B, C) :- N > 1, N1 is N - 1, move(N1, A, C, B), % T(N-1) move(1, A , B, C), % T(1) move(N1, C, B, A). % T(N - 1)