How can $S_n=n$ for the series $S_n=\frac{1}{2}+\frac{3}{4}+\frac{7}{8}+\frac{15}{16}+\cdots$ How can $S_n=n$ for the series $$S_n=\frac{1}{2}+\frac{3}{4}+\frac{7}{8}+\frac{15}{16}+\cdots$$
My try:
We can Re-write $S_n$ as
$$S_n=\frac{0+1}{2}+\frac{1+2}{2^2}+\frac{3+2^2}{2^3}+\frac{7+2^3}{2^4}+\cdots \frac{2^{n-1}-1+2^{n-1}}{2^n}$$
So we get
$$S_n=\frac{1}{2}+\frac{1}{2}+\cdots+\frac{1}{2}+\left(\frac{1}{2^2}+\frac{3}{2^3}+\frac{7}{2^4}+\cdots\right)$$
Hence
$$S_n=\frac{n}{2}+\frac{S_n}{2}$$
Hence
$$S_n=n$$
But the actual answer is entirely different. Whats wrong in my solution?
 A: Your solution is not quite correct because $S_n$ has terms from $\frac{1}{2}$ to $\frac{2^n - 1}{2^n}$, but with your adjusted value, the terms on the right are missing the last value of $S_n$. Thus, the appropriate expression is$$\begin{equation}\begin{aligned}
S_n & = \frac{n}{2} + \frac{S_n - \frac{2^{n} - 1}{2^{n}}}{2} \\
2S_n & = n + S_n - \left(1 - \frac{1}{2^{n}}\right) \\
2S_n & = n + S_n - 1 + \frac{1}{2^{n}} \\
S_n & = n - 1 + \frac{1}{2^{n}}
\end{aligned}\end{equation}\tag{1}\label{eq1}$$
As an alternate solution method, note you have
$$\begin{equation}\begin{aligned}
S_n & = \frac{2-1}{2} + \frac{4-1}{4} + \ldots + \frac{2^n-1}{2^n} \\
& = 1 - \frac{1}{2} + 1 - \frac{1}{4} + \ldots + 1 - \frac{1}{2^n} \\
& = (1 + 1 + \ldots + 1) - \left(\frac{1}{2} + \frac{1}{4} + \ldots + \frac{1}{2^n}\right) \\
& = n - \frac{1}{2}\left(\frac{1 - \frac{1}{2^n}}{1 - \frac{1}{2}}\right) \\
& = n - 1 + \frac{1}{2^n}
\end{aligned}\end{equation}\tag{2}\label{eq2}$$
As you can see, this matches the corrected version of your solution attempt.
You can also check a few values to confirm, e.g., $S_1 = \frac{1}{2}$, $S_2 = 1 + \frac{1}{4} = \frac{5}{4} = \frac{1}{2} + \frac{3}{4}$, etc.
A: Given:
$$S_n=\frac{1}{2}+\frac{3}{4}+\frac{7}{8}+\frac{15}{16}+\cdots+a_n,$$
as pointed out by John Omielan, you are missing the first (or last) term:
$$S_n=\frac{\color{red}0+\color{blue}1}{2}+\frac{\color{red}1+\color{blue}2}{2^2}+\frac{\color{red}3+\color{blue}{2^2}}{2^3}+\frac{\color{red}7+\color{blue}{2^3}}{2^4}+\cdots +\underbrace{\frac{\color{red}{2^{n-1}-1}+\color{blue}{2^{n-1}}}{2^n}}_{a_n=\frac{2^n-1}{2^n}}=\\
\left(\frac{\color{red}0}2+\frac{\color{red}1}{2^2}+\frac{\color{red}3}{2^3}+\frac{\color{red}7}{2^4}+\cdots +\frac{\color{red}{2^{n-1}-1}}{2^n}\right)+
\left(\frac{\color{blue}1}2+\frac{\color{blue}2}{2^2}+\frac{\color{blue}{2^2}}{2^3}+\frac{\color{blue}{2^4}}{2^4}+\cdots +\frac{\color{blue}{2^{n-1}}}{2^n}\right)=\\
\frac12
\left(\color{red}0+\frac{\color{red}1}{2}+\frac{\color{red}3}{2^2}+\frac{\color{red}7}{2^3}+\cdots +\frac{\color{red}{2^{n-1}-1}}{2^{n-1}}\right)+
\left(\frac{\color{blue}1}2+\frac{\color{blue}1}{2}+\frac{\color{blue}{1}}{2}+\frac{\color{blue}{1}}{2}+\cdots +\frac{\color{blue}{1}}{2}\right)=\\
\frac12(0+S_{n-1})+\frac12n=\\
\frac12(S_n-a_n)+\frac12n \Rightarrow \\
S_n=n-a_n=n-\frac{2^{n-1}-1+2^{n-1}}{2^n}=n-\frac{2^n-1}{2^n}=n-\left(1-\frac{1}{2^n}\right)=n-1+\frac1{2^n}.$$
You can prove by mathematical induction: $S_{n}=n-1+\frac1{2^n}$. Indeed:
$$S_n=\color{red}{S_{n-1}}+\color{blue}{a_n}=\color{red}{(n-1)-1+\frac1{2^{n-1}}}+\color{blue}{\frac{2^n-1}{2^n}}=\\
n-1+\frac{-2^n+2+2^n-1}{2^n}=n-1+\frac1{2^n}.$$
