1+2+1/2+3+1/2+1/4........+1/2^n-1 =1+2+3+...+n+1/2+1/4+1/8+.....+1/2^n-1=(1+n)n/2+1/2*(1-1/2^n)/(1-1/2)=(1+n)n/2+1/2*(1-1/2^n)*2=(1+n)n/2+1-1/2^n