procedure hanoi(n, source, target, spare) if n == 0 then return hanoi(n - 1, source, spare, target) move disk n from source to target hanoi(n - 1, spare, target, source) end procedure