procedure main()
write("How many disks are on the towers of Hanoi?")
hanoi(read())
end
procedure hanoi(n:integer, needle1 : 1, needle2 : 2)
local other
if n = 1 then
write("Move disk from ", needle1, " to ", needle2)
else {
other := 6 - needle1 - needle2
hanoi(n-1, needle1, other)
write("Move disk from ", needle1, " to ", needle2)
hanoi(n-1, other, needle2)
}
end