
% towers of hanoi: displays instructions, format
%    move(Number, Src, Dest, Using).
% base case, move one disc (write from where to where)
move(1, A, B, _) :- write('move from '), write(A),
                    write(' to '), write(B), nl.
% general case, move the top N-1 to an intermediate,
%    move the Nth to the destination, then move the N-1
%    from the intermediate to the destination
move(N, Src, Dest, Using) :- number(N), N > 1, M is N-1,
   move(M, Src, Using, Dest), move(1, Src, Dest, Using),
   move(M, Using, Dest, Src).

