Show an example of a function from $\mathbb Z \to \mathbb Z$ that is surjective but not injective 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.
 A: 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.
A: Children in elementary school have eventually heard of the digit sum. Well let the digit sum of $-13$ be $-4$ to make it work over the negative integers.
Every fibre (except the one of zero) is even infinite, since you do not change the digit sum by multiplying by $10$.
A: I would think as follows:  you need the image of the function to be all of $\Bbb Z$ and at least one element of $\Bbb Z$ to be the image of two different integers.  This would be a problem with finite sets, but $\Bbb Z$ is infinite.  We know you can remove one element from $\Bbb Z$ and not change the cardinality, so there is a bijection between $\Bbb Z$ and $\Bbb Z$ minus one element, which might as well be zero. So, given $g: \Bbb Z  \setminus \{0\} \to \Bbb Z$ that is a bijection, let $f$ be the same and send $0$ to $0$.  Now you have two preimages of $0$, the one in $g$ and $0$.
A: Consider
$$f : x \mapsto \left\{ \begin{array}{cc}
x & \textrm{if } x<1 \\
x-1 & \textrm{if } x\geqslant 1
 \end{array}\right.$$
$f$ is surjective and not injective.
