Given a function $f: \mathbf{N}_0 \to \mathbf{N}_0$, defined $$ f(x) = \begin{cases} x+3 & \text{if } x \in \mathbf{N}_{\text{even}} \\ x-1 & \text{if } x \in \mathbf{N}_{\text{odd}} \end{cases} $$

I have to prove that the function is surjective.

My attempt:

Take any y ∈ N even

f(x)=y ⇒ x+3=y ⇒ x=y-3

Note x=y-3 ∈ N even and


Take any y ∈ N odd

f(x)=y ⇒ x-1=y ⇒ x=y+1

Note x=y+1 ∈ N odd and


This shows that f is surjective.


closed as unclear what you're asking by lulu, Did, user90369, John B, kimchi lover Jan 13 '18 at 21:30

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ For which $n$ is $f(n)=1$? $\endgroup$ – lulu Jan 13 '18 at 17:02
  • $\begingroup$ Really? $n=2$ is even so I thought $f(2)=2+3=5$. $\endgroup$ – lulu Jan 13 '18 at 17:04
  • $\begingroup$ Voting to close the question as it is not clear what you are talking about. $\endgroup$ – lulu Jan 13 '18 at 17:06

The function $f$ is not surjective: there is no $n\in\mathbb N_0$ such that $f(n)=1$.


Your proof is not correct: if $y$ is odd, then $y+1$ will not be odd. Similarly if $y$ is even, then $y-3$ won't be even.

If the function was defined from the integers to the integers $\mathbb Z\to\mathbb Z$ then it would be surjective by the following argument (which is the "corrected version" of yours). Given $y$ there are two cases:

  1. if $y$ is even then $x:= y+1$ is odd and we have $f(x)=y$
  2. if $y$ is odd then $x:= y-3$ is even and we have $f(x)=y$

Note however that in your exercise the function is defined $\mathbb N_0 \to\mathbb N_0$. Note that there is no $x\in\mathbb N_0$ that maps to $1$ so the function is not surjective. How to see there is no such $x$? If $x$ was odd then $f(x)=x-1$ would be even, so certainly $f(x)\neq 1$. If $x$ was even $f(x)=x+3\geq 0+3>1$ (here we use that $x\geq 0$ by definition of $x\in\mathbb N_0$)

  • $\begingroup$ So the function is surjective only if the domain and the codomain are the same? $\endgroup$ – Marco Carta Jan 13 '18 at 16:59
  • $\begingroup$ @MarcoCarta Not at all. $\endgroup$ – José Carlos Santos Jan 13 '18 at 17:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.