k=0
for 1 to i
if 2^i<A(i) and A(i)<i then k=k+1
next i

Вот так нельзя?