To obtain towers(n,i,a,f):

If n = 1, then

move the top disk from peg i to peg f

else

apply towers(n - 1,i,f,a)

moves the top disks from peg i to peg f

apply towers(n - 1,a,i,f).