Show that the following function from $\mathbb{Z} \to \mathbb{Z}$ is injective and/or surjective, or neither

discrete mathematicsfunctionsintegers

I have a question that says the following:

Define $$f(n) = \frac{n}{2} + \frac{1-(-1)^n}{4}$$ for all $n \in \mathbb{Z}$. Thus, $ f\colon \mathbb{Z} \to \mathbb{Z}$ , where $\mathbb{Z}$ is the set of all integers. Only one of the following choices is correct. Provide a proof of your choice.

a) $f$ is not a function from $\mathbb{Z} \to \mathbb{Z}$ because $\frac{n}{2}$ is not in $\mathbb{Z}$

b) $f$ is a function and is onto and one-to-one

c) $f$ is a function and is not onto but is one-to-one

d) $f$ is a function and is onto but is not one-to-one

I know a) is not the answer for sure, because for any $n \in \mathbb{Z}$, we get a map to another integer in $\mathbb{Z}$. So it is a function, but I am having a hard time showing that it is injective and/or surjective. Any help appreciated.

Best Answer

Observe that $f(2k-1)=f(2k)=k,$ for all $k \in \Bbb Z.$ This shows that $f$ is not one-to-one but definitely onto.

So $(d)$ is the only correct option.

Related Question