Composed function ..

Given a function $f: \mathbf{N}_0 \to \mathbf{N}_0$, defined $$f(x) = \begin{cases} x+3 & \text{if } x \in \mathbf{N}_{\text{even}} \\ x-1 & \text{if } x \in \mathbf{N}_{\text{odd}} \end{cases}$$

Is the composed function $f o f = x + 2$ if $x ∈ {N}_0$ ?

• @ArsenBerk he just forgot to make some spaces: It should be $x+2$ if $x \in N_0$. – noctusraid Jan 14 '18 at 12:10
• Ah, okay now I see. – ArsenBerk Jan 14 '18 at 12:11

The answer is yes. If you want to justify it, simply note that for $x$ even and $y$ odd we always have $x+y$ is odd.
• If $x$ is even, then $f(x) = x+3$ will give us an odd number and $f(f(x)) = (x+3)-1 = x+2$.
• If $x$ is odd, then $f(x) = x-1$ will give us an even number and $f(f(x)) = (x-1)+3 = x+2$.
Therefore, in general, $f\circ f = x+2$. So you're correct.