.
Give an example of a function
(a) f∶ Z→N that is both 1-1 and onto.
(b) f∶ N→Z that is both 1-1 and onto
~~~~~~~~~~~~~~~~~~~~~~~
(a) f: Z --> N that is both 1-1 and onto.
It may seem to be strange but in Math (Math with the capital M, i.e, in the TRUE Math) you may find different definitions of
what is natural number.
Some mathematicians include 0 (zero) to natural.
Others no. See this Wikipedia article: https://en.wikipedia.org/wiki/Natural_number
https://en.wikipedia.org/wiki/Natural_number
In what follows I will include 0 to naturals (for simplicity, ha-ha-ha).
My example of such function is
f(0) = 0,
f(n) = 2n for positive integer n, and
f(n) = 2|n|-1 for negative integer n.
(in other words, positive n go to the even positive integers; negative n go to the odd positive integers.)
It is clear that this map is "onto", and
It is clear that it is "1-1".
(b) You can easily construct an example for (b), reversing the function from (a).