Tower of Hanoi


The tower of disks on A must be moved to C one disk at a time
and always with smaller disks on top of larger ones.

This classical puzzel is easily solved using a recursive function.

5 disks are moved in 31 steps.

N disks are moved in 2N - 1 steps. The legend tells that the monks
at the monastery in Hanoi are moving 64 disks non-stop and that the world
will come to an end when they finish. With one disk every two seconds (as here)
this task will take about 85 times the age of the universe!