1/(1+x)+2/(1+x^2)+4/(1+x^4)+8/(1+x^8)+…+n/(1+x^n)-2n/(1-x^2n)
=1/(1-x)+1/(1+x)+2/(1+x^2)+4/(1+x^4)+8/(1+x^8)+…+n/(1+x^n)-2n/(1-x^2n)-1/(1-x)
=(1+x+1-x)/(1-x^2)+2/(1+x^2)+4/(1+x^4)+8/(1+x^8)+…+n/(1+x^n)-2n/(1-x^2n)-1/(1-x)
=2/(1-x^2)+2/(1+x^2)+4/(1+x^4)+8/(1+x^8)+…+n/(1+x^n)-2n/(1-x^2n)-1/(1-x)
=4/(1-x^4)+4/(1+x^4)+8/(1+x^8)+…+n/(1+x^n)-2n/(1-x^2n)-1/(1-x)
=8/(1-x^8)+8/(1+x^8)+…+n/(1+x^n)-2n/(1-x^2n)-1/(1-x)
.
=2n/(1-x^2n)-2n/(1-x^2n)-1/(1-x)
=-1/(1-x)
=1/(x-1)