Reconstructing initial conditions [in the *3n+1* problems]

Given a particular starting value of n, it is difficult to predict what precise sequence of even and odd values will be obtained in the system on page 123. But given t steps in this sequence as a list of 0's and 1's, the following function will reconstruct the rightmost t digits in the starting value of n:

IntegerDigits[First[Fold[{Mod[If[OddQ[#2], 2 First[#] - 1, 2 First[#] PowerMod[5, -1, Last[#]]], Last[#]], 2 Last[#]}&, {0, 2}, Reverse[list]]], 2, Length[list]]