# Proof of range of piecewise function

Let $$f: \mathbb{Z} \rightarrow \mathbb{Z}$$ be defined by, for all $$n \in \mathbb{N}$$

$$f(n)=$$ $$\begin{cases} n-1 & \text{if n is even}\\ n+5 & \text{if n is odd} \end{cases}$$

Prove that ran $$f = \mathbb{Z}$$

Is it not enough to simply plug in and show using definitions of odd and even? How would you prove this?

Let $$m$$ be any integer. It is either even or odd. In either case we shall show that $$f(n)=m$$ for some integer $$n$$. If $$m$$ is odd then $$f(m+1)=m$$ and if $$m$$ is even then $$f(m-5)=m$$. Thus we can take $$n=m+1$$ when $$m$$ is odd and $$n=m-5$$ when $$m$$ is even.
• Thus showing the range $f = \mathbb{Z}$ makes perfect sense. – Forextrader Feb 25 at 23:43