Tower of Hanoi Algorithm Recursive

Tower of Hanoi Algorithm:

Tower of Hanoi is a famous recursive problem which is based on 3 pegs and a set of the disc with different sizes.

Algorithm:

Algorithm fnTower_of_Hanoi(A, B, C, N)
{
 if(N==1)
{
  Move top disc from A to C (A->C);
  return;
}
else
{
  fnTower_of_Hanoi(A, C, B, N-1);
  fnTower_of_Hanoi(A, B, C, 1);
  fnTower_of_Hanoi(B, A, C, N-1);
}
}  // End of Algorithm