Bijection function from non-negative integers to integers

1k Views Asked by At

What is an example of a function from the set of non-negative integers (0, 1, 2, 3..) to the set of integers? The function has to be bijective.

2

There are 2 best solutions below

0
On

$$ f(n) = \begin{cases} n/2 & \mbox{even } n \\ -(n+1)/2 & \mbox{odd } n \\ \end{cases} $$ $$ f^{-1}(n) = \begin{cases} 2n & \mbox{if } n \geq 0 \\ -2n-1 & \mbox{if } n < 0 \\ \end{cases}$$ $$ f: \{0,1,2,3,4,5,6,...\} \rightarrow \{0,-1,1,-2,2,-3,3,...\} $$ $$ f^{-1}: \{...,-3,-2,-1,0,1,2,3,...\} \rightarrow \{...,5,3,1,0,2,4,6,...\} $$ The function $f$ is bijective

0
On

\begin{align}f:\mathbb N_0& \rightarrow \mathbb Z \\ n &\mapsto \frac{1}{4}(1-(-1)^n(2n+1)) \end{align}