1. INVARIENT CONDITION FOR HANOI TOWERS
If we were inclinedtothinkina more mathematical fashion,we mightapproachthisproblemalittle
differently.Luckyforus the mathbehindTowersof Hanoi isverywell understood,butevenif itwasn't
the ideaisthe same.Let'shave a look.
Mathematically, we want to work out a formula for how many steps (Tn) it takes to
transfer n discs from the source to the destination peg. Looking at the smaller cases and counting
the steps manually we see the following.
when n=1, Tn=1
when n=2, Tn=3
when n=3, Tn=7
when n=4, Tn=15
From this we can start to infer a pattern. Every time we increase the number of discs by 1, we
need to double the number of steps and add 1, which means we can express the number of
steps Tn taken to transfer n discs based on the number of steps taken to transfer n−1 discs:
Tn=2Tn−1+1 where n>0