I came across this question and wasn't too sure how to do it. Can anyone explain this? Construct a bijective function f : N → Z. Also, find its inverse.
Any help is appreciated.
I came across this question and wasn't too sure how to do it. Can anyone explain this? Construct a bijective function f : N → Z. Also, find its inverse.
Any help is appreciated.
Define $$f:n\mapsto \begin{cases} \frac n2 \quad &\text{if } n\text{ even},\\ -\frac{n+1}2 \quad &\text{if } n\text{ odd}\end{cases},$$
assuming the convention $0\in\mathbb N$.
The inverse is
$$f^{-1}:n\mapsto \begin{cases} 2n &\quad \text{if } n\ge 0,\\ -2n-1 &\quad \text{if } n<0\end{cases}.$$
Hint: $f: \mathbb N \to \mathbb Z$, where $f(0)=0$, $f(2n)=n$ and $f(2n-1)=-n$, for all $n\geqslant 1$.