TITLE: How can we prove $\pi =1+\frac{1}{2}+\frac{1}{3}+\frac{1}{4}-\frac{1}{5}+\frac{1}{6}+\frac{1}{7}+\cdots\,$?
QUESTION [26 upvotes]: I saw the beautiful result that was proved  by Euler  in Wikipedia but I do not know how it can be proved. 
$$\pi =1 + \frac{1}{2} + \frac{1}{3} + \frac{1}{4} - \frac{1}{5} + \frac{1}{6} + \frac{1}{7} + \frac{1}{8} + \frac{1}{9} - \frac{1}{10} +  \frac{1}{11} + \frac{1}{12} - \frac{1}{13} + \cdots $$
After the first two terms, the signs are determined as follows: If the denominator is a prime of the form $4m - 1$, the sign is positive; if the denominator is a prime of the form $4m + 1$, the sign is negative; for composite numbers, the sign is equal the product of the signs of its factors.

There is reference in this Wikipedia page to
 Carl B. Boyer's A History of Mathematics, Chapter 21., p. 488-489. I found the book on the internet but there is no proof in the book.
Thanks a lot for your help.

REPLY [23 votes]: We want to compute 
$$S=\sum_{m=1}^{\infty}\frac{(-1)^{s(m)}}{m},$$
where $s(m)$ counts the number of appearances of primes of the form $4k+1$ in the prime decomposition of $m$. Note that
$$S=\sum_{n=0}^{\infty}\frac{(-1)^{s(2n+1)}}{2n+1}+\frac{S}{2}\quad\Longrightarrow \quad
\frac{S}{2}=\sum_{n=0}^{\infty}\frac{(-1)^{s(2n+1)}}{2n+1}.\tag{1}$$
But the latter sum can be written as
$$\sum_{n=0}^{\infty}\frac{(-1)^{s(2n+1)}}{2n+1}=\prod_{k=2}^{\infty}\left(1+\dfrac{(-1)^{\frac{p_{{k}}-1}{2}}}{p_{k}} \right )^{-1},\tag{2}$$
where the product on the right is taken over odd primes. To show the equality, expand each factor on the right  into geometric series and multiply them. Further, as shown by answers to this question, this product is equal to $\pi/2$. Being combined with (1), this gives $S=\pi$.