How to construct an example where $\sum_{n=1}^{+\infty} a_n$ diverges and $\prod_{n=1}^{+\infty} (1+a_n)$ converges? 
My Problem: Construct an example where
$$ \sum_{n=1}^{+\infty} a_n \quad \text{diverges}, \qquad \text{and}\qquad \prod_{n=1}^{+\infty} (1 + a_n) \quad \text{converges}$$

My thoughts:
By '$\prod _{n=1}^{+\infty} (1 + a_n)$ converges', we have $a_n \to 0$, and by '$\sum_{n=1}^{+\infty} a_n$ diverges', we know that the sign of $\{a_n\}$ is not fixed. But I have no idea how to construct the $a_n$.
Please give me some hints to do it. Thanks a lot!
And how can I construct the ${a_n}$ when it is not constant?
 A: Some author says that $\prod_{n=1}^{\infty}(1 + a_n)$ is convergent only if
$$ \lim_{N\to\infty} \prod_{n=1}^{N} (1+a_n) \in \mathbb{C}\setminus\{0\}. $$
This definition has some advantages over the more lenient version that allows $0$ as a possible value of infinite product, see the related Wikipedia article for instance.
Even with this definition, we are still able to construct an example.

Construction. Define $(a_n)_{n\geq 1}$ so as to satisfy
$$ (1+a_n)_{n\geq 1} = \left( 1, \quad \frac{2}{1}, \frac{1}{2}, \quad \frac{3}{2}, \frac{2}{3}, \frac{3}{2}, \frac{2}{3}, \quad \frac{4}{3}, \frac{3}{4}, \frac{4}{3}, \frac{3}{4}, \frac{4}{3}, \frac{3}{4}, \frac{4}{3}, \frac{3}{4}, \quad \ldots \right) $$
By the construction, it is clear that $\prod_{n=1}^{\infty} (1 + a_n) = 1$. On the other hand,
$$ (a_n)_{n\geq 1} = \left( 0, \quad \frac{1}{1}, -\frac{1}{2}, \quad \frac{1}{2}, -\frac{1}{3}, \frac{1}{2}, -\frac{1}{3}, \quad \frac{1}{3}, -\frac{1}{4}, \frac{1}{3}, -\frac{1}{4}, \frac{1}{3}, -\frac{1}{4}, \frac{1}{3}, -\frac{1}{4}, \quad \ldots \right), $$
and so,
$$ \sum_{n-1}^{2^N - 1} a_n
= \sum_{k=2}^{N} \sum_{n=2^{k-1}}^{2^k - 1} a_n
= \sum_{k=2}^{N} 2^{k-2} \left( \frac{1}{k-1} - \frac{1}{k} \right)
= \sum_{k=2}^{N} \frac{2^{k-2}}{k(k-1)} $$
and this diverges as $N \to \infty$. Using this, it is then not hard to check that $\sum_{n=1}^{\infty} a_n = \infty$.
A: We have to do it so that convergence is conditional, not absolute.
Example:
$$
a_n = -1+\exp\left(\frac{(-1)^n}{\sqrt{n}}\right) .
$$
Then, as $n \to \infty$, Taylor's theorem yields
$$
a_n = -1+1+\frac{(-1)^n}{\sqrt{n}}+\frac{1}{2n}+O\left(\frac{1}{n^{3/2}}\right) .
$$
Write
$$
a_n = \frac{(-1)^n}{\sqrt{n}}+\frac{1}{2n}+b_n
$$
Now the partial sum is
$$
\sum_{n=1}^N a_n = \sum_{n=1}^N \frac{(-1)^n}{\sqrt{n}}
+\sum_{n=1}^N \frac{1}{2n}+\sum_{n=1}^N b_n
$$
where, as $N \to \infty$, we have
\begin{align}
\sum_{n=1}^N \frac{(-1)^n}{\sqrt{n}}\quad &\text{converges,}
\\ \sum_{n=1}^N \frac{1}{2n}\quad&\text{diverges to} +\infty,
\\ \sum_{n=1}^N b_n\quad &\text{converges.}
\end{align}
So the series $\sum a_n$ diverges to $+\infty$.
On the other hand,
$$
\log(1+a_n) = \frac{(-1)^n}{\sqrt{n}}
$$
and
$\sum \log(1+a_n)$
converges (alternating series) so $\prod(1+a_n)$ converges.
