# Prove that this function is onto and one-to-one

$f:Z \rightarrow Z$

$f(x) = x-5$ , when $x$ is odd

$f(x) = x+3$ , when $x$ is even

It seems that it is not onto, because not all integers are covered, but how do you show this?

-
But it is onto! look at the individual y-sets for each of those functions. You see that the first function produceds a y-set of all even numbers, and the second function produces a y-set of all odd numbers. Combining them makes all the integers. – mathguy Nov 9 '12 at 4:26
Following on mathguy's comment: if X is odd, what is $f^{-1}(X)?$ and if X is even, what is $f^{-1}(X)$> – Ross Millikan Nov 9 '12 at 4:30

Pick any $a\in\mathbb{Z}$.
if $a$ is odd we know that $a - 3$ is even (since $a - 2$ is clearly odd) so $f(a - 3) = a$.
if $a$ is even we know that $a + 5$ is odd (since $a + 4$ is clearly even) so $f(a + 5) = a$.
This function is also one to one, and I leave this partially to you, to see this note that for odd $x$, $f(x)$ only hits even numbers and never hits the same number twice. And for even $x$ this only hits odd numbers.