Consider you only know how to move one ring.
Now you are asked to move 4 rings from tower A to tower C.
Understand this notation $<n P Q R>$, this means I want to move n rings from P to Q using R, we are going to pass n = 4, P = A, Q = C, R = B in the function.
Now we have $<4 A C B>$ i.e. move 4 rings from A to C using B.
You : I want to move 4 rings from A to C.$<4 A C B>$ (our first function call)
Me : move 3 rings from A to B $<3 A B C>$ (first recursive call).

then move one (yellow) ring from A to C $<1 A C B>$ (this is the only move you know).

then move those three rings from B to C $<3 B C A>$ (we will make this call when we have moved 3 rings from A to B).
thus, **a <4 A C B> call is <3 A B C>,<1 A C B>,<3 B C A> executed in order.
You: I don’t know how to move 3 rings from A to B(thus we have a three ring problem <3 A B C> ).
ME: move 2 rings from A to C <2 A C B> (second recursive call).

<1 A B C>

then <2 C B A >

thus a <3 A B C> call is <2 A C B><1 A B C><2 C B A> executed in order.
But the thing is you didn’t know how to how to move the 2 rings**<2 A C B >.**
thus, we have a 2 ring problem**.<2 A C B>**(third recursive call).
this is how <2 A C B> executes (you know all the moves in this call as you know how to move 1 ring):-
<2 A C B> call is <1 A B C> <1 A C B > <1 B C A> executed in order
<1 A B C> return;

<1 A C B >return;

<1 B C A>return;

this completes the <2 A C B> call, hence it also returns to the calling function
<3 A B C >;
next is <1 A B C> return;

next call is made to <2 C B A> all the subsequent move are the base condition recursive calls
<1 C A B>return;

<1 C B A> return;

<1 A B C> return;

This concludes the <3 A B C> call and it returns;
Next call is <1 A C B> return;

Next call is <3 B C A>
you must have an idea now how it would be done.
<3 B C A> is <2 B A C><1 B C A><2 A C B>
now we will execute <2 B A C>
<2 B A C> is <1 B C A><1 B A C ><1 C A B>executed in order.
<1 B C A>return;

<1 B A C >return;

<1 C A B>return;

this concludes the <2 B A C> part of <3 B C A>. i.e. <2 B A C>returns;
next call is:-
<1 B C A>return;

next call is <2 A C B>
<2 A C B> is <1 A B C><1 A C B><1 B C A> executed in order.
<1 A B C>return;

<1 A C B>return;

<1 B C A>return;

<2 A C B> returns;

<3 B C A> returns;
<4 A C B >returns;
You: I want to move n rings from A to C.
Me: **$<n-1 A B C>
<$1 A C B$>
<n-1 B C A>$…**.
Source : Quora