Define an $\mathbb{N}$ to $\mathbb{N}$ function that is Hi I'm preparing for an exam and was going through exercises on functions. I stumbled upon this question and didn't know how to answer it. 
Give an $\mathbb{N}$ to $\mathbb{N}$ function that
is one-to-one but not onto,
Answer:  $f(n)=n+1$
onto but not one-to-one,
Answer: $F(n) =\begin{cases} n-1 &\mbox{if } n > 0 \\ 0 & \mbox{if } n= 0\end{cases}$
both one-to-one and onto (but different from $\text{id}_{\mathbb{N}}$), 
Answer: $F(n) =\begin{cases} n-1 &\mbox{if } n\text{ is odd}\\ n+1 &\mbox{if }n\text{ is even}\end{cases}$
neither one-to-one nor onto.
Answer: $F(n) = 42$
When I looked at the answers to try & understand I couldn't figure out why they were correct. Why was 42 chosen as a neither one-to-one or onto function (based on what equation)? And how does $n-1$ or $n+1$ define the domain & codomain which then can determine the type of the function? 
Thank you very much! 
 A: I'll remark on two of your four problems, and hopefully that will be enough to get you going on the others. First, you have already been given the domain and codomain for your function $f$, namely $\mathbb{N}$ and $\mathbb{N}$. Thus, for every one of of your problems you are considering the mapping $f\colon\mathbb{N}\to\mathbb{N}$ defined by ___ ; that is, your domain and codomain are the same for all of your problems but only the definition of the mapping changes (what is being mapped to what, specifically). 
One-to-one but not onto: Here, $f(n)=n+1$ works because $n_1+1=n_2+1\Leftrightarrow n_1=n_2$ (which means $f$ is one-to-one), but is $0\in\mathbb{N}$ ever mapped to? No; thus, $f$ is not onto. 
Neither one-to-one nor onto: Here, $f(n)=42$. Well, $f(7)=42=f(8)$ but $7\neq8$; thus, $f$ is not one-to-one. Also, is $0\in\mathbb{N}$ ever mapped to? For that matter, is anything other than $42$ ever mapped to? No. Thus, $f$ is not onto either. 
Can you see how to apply that reasoning to your other problems? 
