[Math] prove that the function is surjective but not injective.

functions

$f: \mathbb N \to \mathbb N $ be defined as $f(n) = \begin{cases} \dfrac{n}{2}, & \text{if $n$ is even} \\ \dfrac{n+1}{2}, & \text{if $n$ is odd} \end{cases}$

How do I prove that the function is surjective but not injective?

Attempt:

It's not injective because $f(1)=f(2)$ but I doubt that it's a valid proof.

I am new to proof writing in functions therefore I am unable to frame the language for surjective proof. I know that for a surjective function range of function = co domain of function.

Best Answer

For each $n \in \Bbb N,$

$$f (2n)=n $$

so, it is surjective.

Related Question