HELP! Need help with this algorithm

I have to write code to document the steps to the puzzle of the

Tower of Hanoi. Basically, in this puzzle there are three poles and

rings of increasing size on the 1st pole. The object is to get the

rings to the 2nd

pole in increasing size, but you can only move one piece at a time,

and a bigger piece can't be on a smaller one. Example:

Start:

Pole 1 Pole 2 Pole 3

1

2

3

4

Object:

Pole 1 Pole 2 Pole 3

1

2

3

4

You have to use the conditions above

Here is my algorithm:

The disks will always move from 1 to 3 and then back to 1. But the nth

disk can't change direction to come back until the n+1 disk moves 1

spot. Example: 3 variable disk1, disk2, disk3 can have value of 0, 1,

or 2 for

the poles 1, 2, and 3 respectively. Here is the steps for 3 disks.

Disk1, 2, 3 = 0 and you want to end up with Disk 1, 2, 3 = 1

Disk1 =1

Disk 1 =2

Disk 2 =1

Disk 1 = 1

Disk 1=0

Disk2 =2

Disk 1 =1

Disk 1 = 2

Disk 3 =1

Disk 1 = 1

Disk 1 = 0

Disk 2 = 1

Disk 1 =1

That will accomplish my task.

My problem is coding the above algorithm, does recursion need to be

used? Are there some kind of nested for loops with if statements??

Thanks