Answer
Both \(f(n)=\lfloor n/2 \rfloor\) and
\[
g(n)=
\begin{cases}
n,& n\ge0\\
n+1,& n<0
\end{cases}
\] are onto \(\mathbb{Z}\) but fail to be one‐to‐one. Thus they are surjective, non‐injective functions from \(\mathbb{Z}\) to \(\mathbb{Z}\).
Work Step by Step
Below are two typical examples of functions \(f\colon \mathbb{Z}\to \mathbb{Z}\) that are **onto** (surjective) but **not** one‐to‐one (injective). In each case, you can check that every integer in the codomain is hit by some integer in the domain, but at least two distinct integers in the domain map to the same value—thus failing injectivity.
---
## Example 1: \(f(n) = \lfloor n/2 \rfloor\)
1. **Definition**:
\[
f(n) \;=\; \left\lfloor \frac{n}{2} \right\rfloor,
\]
where \(\lfloor x \rfloor\) is the greatest integer less than or equal to \(x\).
2. **Surjectivity**:
- Given any integer \(k\), consider \(n=2k\) or \(n=2k+1\).
- In either case, \(\lfloor n/2 \rfloor = k\).
- Hence every integer \(k\) in the codomain has a preimage, so \(f\) is onto.
3. **Not one‐to‐one**:
- For example, \(f(2k) = \lfloor 2k/2\rfloor = k\) and \(f(2k+1) = \lfloor (2k+1)/2\rfloor = k\).
- Thus \(2k\) and \(2k+1\) (two distinct integers) map to the **same** integer \(k\).
- This fails injectivity.
---
## Example 2
Define
\[
g(n) \;=\;
\begin{cases}
n, & \text{if } n \ge 0,\\[6pt]
n + 1, & \text{if } n < 0.
\end{cases}
\]
1. **Surjectivity**:
- If \(y \ge 0\), choose \(n=y\). Then \(g(n)=y\).
- If \(y < 0\), choose \(n = y - 1\). Note \(y-1 < 0\), so \(g(n) = (y-1)+1 = y\).
- In all cases, every integer \(y\) has a preimage \(n\). Thus \(g\) is onto.
2. **Not one‐to‐one**:
- Observe \(g(-1) = -1 + 1 = 0\) and \(g(0) = 0\).
- Two distinct inputs (\(-1\) and \(0\)) map to the **same** output \(0\).
- Hence \(g\) is not injective.