# Function from $\mathbb{Z^+}$ to $\mathbb{Z^+}$ that is neither one-to-one nor onto?

I am thinking of something like $$f(x) = 8$$

Does this make sense? It seems a bit simple to me so I'm not sure.

My reasoning is that this function is not one-to-one because f takes same value for all domain. It's also not onto because range isn't equal to codomain since here the range is just the number 8.

Thanks!

• Your example is good. Others include $f(x)=2\left\lfloor\frac x2\right\rfloor$ and $f(x)=2+\cos\frac{n\pi}2$ Commented Jun 9, 2020 at 3:48
• "Does this make sense?" Makes perfect sense. "It seems a bit simple to me so I'm not sure." Nothing wrong with simple if it works. (And you know what.... despite the picky and confusing definitions and all the things to memorize.... this actually wasn't supposed to be a hard problem.) Commented Jun 9, 2020 at 3:50
• "My reasoning is that this function is not one-to-one because f takes same value for all domain." Which means there are multiple values of $x,y$ not equal where $f(x)=f(y)$ but $x\ne y$. So not one-to one. You've got it. That's exactly right. "It's also not onto because range isn't equal to codomain since here the range is just the number 8." So there are values, many values, such as $7$ or $9$ or ... anything that isn't $8$ that are not mapped to. Ex. there is no $x$ so that $f(x) =7$ So it's not onto.... You've got this down cold, kid. Commented Jun 9, 2020 at 3:52
• If you wan to be literal and constructionist you can: To make it not one-to-one let $f(1)=f(2)=1$. To make in not onto make it so that $f(x)$ is never equal to $2$. All the rest can do whatever the heck they want. Just let $f(x) = x$ for $x > 2$ to keep it simple. The idea is functions can be whatever you want so making one do whatever you want doesn't need to be hard. You did just fine. Commented Jun 9, 2020 at 3:56