Is there a function $f:{\mathbb N}\to{\mathbb N}$ that is neither injective nor surjective? [closed]

Is there a function $f:{\mathbb N}\to{\mathbb N}$ that is neither injective nor surjective ?

I came up with $n\mapsto\sin n$ as not all outputs are mapped and some inputs have the same output, but then I realized $\sin n$ doesn't produce a natural number. I have to map the natural numbers to the natural numbers.

I also came up with other ones but they always seem to be total and injective or total and subjective.

closed as unclear what you're asking by user21820, Ethan Bolker, B. Mehta, Namaste, DidDec 12 '17 at 9:46

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Do you mean a total function, maybe? – Bram28 Dec 11 '17 at 4:37
• I think a total relation is one where every pair of elements is comparable. So to speak, for every $x,y$ either $(x,y)$ or $(y,x)$ belongs in the relation. He now wants a non-injective relation i.e. two elements with same second component but different first component, but also non-surjective i.e. there is some natural number that is not the second component of any element. That is what I think. – астон вілла олоф мэллбэрг Dec 11 '17 at 4:42
• I was suppose to look for a relation from the natural set to the natural set with the above condition. So technically a function. – Jose Ramirez Dec 11 '17 at 4:43
• I think @астонвіллаолофмэллбэрг may be right, and you misunderstood what the question was trying to ask (it's certainly far more interesting that way). – Noah Schweber Dec 11 '17 at 4:47
• @астонвіллаолофмэллбэрг Well, there is no total relation that is non-surjective relation: for it to be total, it needs to be reflexive, and is therefore automatically surjective. – Bram28 Dec 11 '17 at 4:59

4 Answers

When in doubt, don't do anything complicated: $$f(n)=17.$$ (Of course, you may have additional conditions you want satisfied, but you haven't mentioned them.)

• @JozemiteApps Yes it does. It takes in a natural number and spits out a natural number. What do you think the phrase means? – Noah Schweber Dec 11 '17 at 4:41
• @JozemiteApps What do you think the term surjective means? – DanielV Dec 11 '17 at 4:46
• Why not $f(n)=42$? – Niyoko Yuliawan Dec 11 '17 at 5:22
• @NiyokoYuliawan: This question isn't that important. :) – Hurkyl Dec 11 '17 at 9:02
• That part was easy. Now we have to find out what's special about 17. – Peter A. Schneider Dec 11 '17 at 16:30

$$n\to\sin n\color{red}\pi$$ (Actually, this is equivalent to $n\to 0$ and thus in the same vein as Schweber's answer. I couldn't resist tacking on to the function in the question though.)

• Also, more aligned with OP's initial attempt at solving problem. But I actually up-voted your answer because I learned something new - latex $\color{red}coloring$! – CopyPasteIt Dec 11 '17 at 19:40

How about $f(n) = n^2-n$?

Total, as $f(n)$ is defined for each $n$

Not injective, as $f(0)=f(1)$

Not surjective, as there is no $n$ such that $f(n)=1$

• This is injective if you consider the "natural numbers" not to include zero. – M.Herzkamp Dec 11 '17 at 16:17

There are lots of fine answers given already, but possibly you'll enjoy this one, too:

$$n\mapsto n(1+\cos n\pi)$$