Lời giải:
Xét \(A=2^0+2^1+2^2+...+2^{n+1}\)
\(\Rightarrow 2A=2^1+2^2+2^3+..+2^{n+2}\)
Trừ theo vế:
\(A=2A-A=(2^1+2^2+2^3+...+2^{n+2})-(2^0+2^1+2^2+...+2^{n+1})=2^{n+2}-2^0=2^{n+2}-1\)
Vậy \(2^{n+2}-1=511\Rightarrow 2^{n+2}=512=2^9\Rightarrow n+2=9\Rightarrow n=7\)