What you did recursively is ...
- Move (n - 1) from peg1 to peg3
- Move 1 from peg1 to peg3
- Move (n - 1) from peg1 to peg3
.. which is not what you want. Keep thinking, you will get it.Some things to consider:
- Distribute the discs on two intermediates.
- Keep track of the order in which discs are assembled on the intermediates.