Task

Solve the   Towers of Hanoi   problem with recursion.




class MAIN is
 
  move(ndisks, from, to, via:INT) is
    if ndisks = 1 then
      #OUT + "Move disk from pole " + from + " to pole " + to + "\n";
    else
      move(ndisks-1, from, via, to);
      move(1, from, to, via);
      move(ndisks-1, via, to, from);
    end;
  end;
 
  main is
    move(4, 1, 2, 3);
  end;
end;