# Half of half by chance

We are given $$2^n$$ numbers: $$1,2,...,2^n$$ ($$n$$ is integer). Then repeat $$n$$ times the following process: split those numbers in half and flip a coin with $$p$$ probability for heads. If the result for a half is tails we ignore that certain half otherwise we proceed. For example: if $$n=2$$ then we have the numbers $$1$$, $$2$$, $$3$$, $$4$$. We flip the coin $$2$$ times and let's suppose the result is $$T$$, $$H$$. So now we are dealing with $$3$$, $$4$$. We flip again the coin $$2$$ times so if the result is $$H$$, $$T$$ then only $$3$$ remains. How many numbers remain in average in this experiment?

I have calculated that in average $$2^n p^n$$ numbers remain. Is it correct?

The number of integers remaining is 0 if at least one of the flips is TT, and it is $$2^i$$ if exactly $$i$$ flips are HH, and remaining are TH or HT. Thus, the average number of integers remaining is $$(2p)^n$$.