Task

Solve the   Towers of Hanoi   problem with recursion.




 
Hanoi := proc(n::posint,a,b,c)
   if n = 1 then
       printf("Move disk from tower %a to tower %a.\n",a,c);
   else
       Hanoi(n-1,a,c,b);
       Hanoi(1,a,b,c);
       Hanoi(n-1,b,a,c);
    fi;
end:
 
printf("Moving 2 disks from tower A to tower C using tower B.\n");
Hanoi(2,A,B,C);
 