[Math] Show an example of a function from $\mathbb Z \to \mathbb Z$ that is surjective but not injective

discrete mathematics

The question I am working on is this…
Give an example of a surjective function from $\mathbb Z \to \mathbb Z$ that is not injective.

My question is simple, when it is worded as above, (which I can't seem to get a straight answer on from others) am I able to put restrictions on this, as an example, only use the positive integers with the formula I create to prove that my formula is surjective? To me, I see this as looking at the infinite set of integers and proving that the infinite set of integers applies to whatever my formula is and that I must prove based on that set of infinite integers that the function I create is surjective.

So where am I misunderstanding…someone told me as a hint that I should think about piecewise functions.

Comprehension of surjective and injective I got, just the wording of the question throws me off. Don't want answer, just trying to get a clue.

Best Answer

I would go with what that person said, try splitting just the positive integers into two parts, one part getting mapped to the negative integers and one part getting mapped to the non-negative integers, and then do the same thing with the negative integers. That way, everything gets mapped into Z twice.