This is an exercise from Mendelson's Introduction to Topology, page 101.
THEOREM
For each $n\in \Bbb N$, let $X_n$ be the discrete two-point topological space $\{0,2\}$. Define the product space $X=\prod\limits_{n\in \mathbb N}X_n\;$. Let $f:X\to [0,1]$ be defined as
$f(x)=\sum_{n=1}^\infty \frac{x(n)}{3^n}$
Then $f$ is one-one and continuous.
PROOF (Revised)
We first prove $f$ is one-one. To this end, suppose we had $\sum_{k\geqslant 1}\frac{x_n}{3^n}=0$ with $x_n\in\{0,-2,2\}$. I claim first there cannot be any $K$ with $x_K=-2$. Indeed, let $K$ be the least index with $x_K=-2$. I claim that $x_k=0$ if $k
there is no way the sum would equal zero if some $x_k$ with $k
This means there cannot exist $k$ with $x_K=-2$. Thus $x_k\in \{0,2\}$. Since the sum is zero, all nonnegative terms must be zero, so the sequence is identically zero.
We now prove $f$ is continuous. Let $a\in X$ and $\epsilon >0$ be given. The claim is that given the open ball $B(f(a);\epsilon)$, we can choose $k$ so that
$\tag 1 P_k=\bigcap_{i=1}^k p_i^{-1}(a(i))\subset f^{-1}(B)$
where $p_i:X\to \{0,2\}$ is the projection to the $i$th coordinate. Since $f$ is one-one, $(1)$ is the same as
$f(P_k)\subset B$
Note that for any point $x\in P_k$, the difference $|f(x)-f(a)|$ is at most $3^{-k}$, precisely when $x(n)=2$ and $a(n)=0$ for $n\geq k+1$ (or viceversa):
$\sum\limits_{n = k + 1}^{ + \infty } {\frac{2}{{{3^n}}}} = \frac{1}{{{3^k}}}$
Thus we may choose $k$ such that $3^{-k}<\epsilon$. It will follow that $f(P_k)\subset B$, and $f$ will be continuous.