function $[0,1]\to [0,1]\setminus M$

Let $M=\{\frac{1}{n} : n\in\mathbb{N}\}$.

I am trying to find a simple surjective and injective function $[0,1]\to [0,1]\setminus M$.

let define that $[0,1]\setminus M = Y$.

I can't understand how to handle with questions like this. I understand that the set $Y$ has all the elements as $[0,1]$ without elements like $1,\frac{1}{2},\frac{1}{3},...\frac{1}{n}$ but for example if I want to send $1$, what the value of function $f(1)$ will be if all other elements are already taken and this function should be injective (because $Y\subseteq [0,1]$).

$$f(x) = \begin{cases} x & \nexists k \in \Bbb N: x = \frac 2k \\ \frac 2{2k-1} & \exists k \in \Bbb N: x = \frac 2k \end{cases}$$
• You should have an explicit $f(0)=0$ case. – Henning Makholm Dec 30 '17 at 1:02
• Because $\frac{1}{2x}$ is not defined (and $x=\frac2k$ is false) for $x=0$. – Henning Makholm Dec 30 '17 at 1:04