Function $g:\mathbb N\to\mathbb N$ neither injective nor surjective

discrete mathematicsfunctions

Question: "Give an example of a function $g:\mathbb N\to\mathbb N$ that is neither injective nor surjective."

I wanted to check whether this is a valid answer.

$$g(n)=\vert\lfloor{\sqrt{n+1}}\rfloor\vert$$
It is not injective because e.g., $g(0)=g(1)=g(2)=1$ and $0\neq1\neq2.$

It is not surjective because $g(n)\neq0$ for any $n\in\mathbb N$.

Best Answer

Overly complicated, but indeed correct.

Related Question