Task

Solve the   Towers of Hanoi   problem with recursion.




function hanoi(n, a, b, c) {
	if (n>0) {
		hanoi(n-1, a, c, b)
		printf("Move from %f to %f\n", a, b)
		hanoi(n-1, c, b, a)
	}
}
 
hanoi(3, 1, 2, 3)
 
Move from 1 to 2
Move from 1 to 3
Move from 2 to 3
Move from 1 to 2
Move from 3 to 1
Move from 3 to 2
Move from 1 to 2