Example. An invertible enumeration of the integers [00MJ]

We can define a bijective enumeration of the integers by “zigzagging” between the positive and the negative following the pattern{\mathopen {}\left (0, -1, 1,-2,2,-3,3,\ldots \right )\mathclose {}}:

\begin {aligned} e&\colon \mathbb {N}\twoheadrightarrow \mathbb {Z}\\ e{\mathopen {}\left (i\right )\mathclose {}} &= \begin {cases} 0 &\text {when } i=0\\ i\div 2 &\text {when } i > 0 \land 2\mid i\\ -{\mathopen {}\left (i+1\right )\mathclose {}}\div 2 &\text {when } i > 0 \land \lnot {\mathopen {}\left (2\mid i\right )\mathclose {}} \end {cases} \end {aligned}