Question:
Give examples of two functions $f: N \rightarrow N$ and $g: N \rightarrow N$, such that $g$ of is onto but $f$ is not onto.
Solution:
Let us consider a function $f: N \rightarrow N$ given by $f(x)=x+1$, which is not onto.
[This not onto because if we take 0 in N (co-domain), then,
0=x+1
$\Rightarrow x=-1 \notin N]$
Let us consider $g: N \rightarrow N$ given by
$g(x)=\left\{\begin{array}{l}x-1, \text { if } x>1 \\ 1, \text { if } x=1\end{array}\right.$
Now, let us find $(g o f)(x)$
Case 1: $x>1$
$(g o f)(x)=g(f(x))=g(x+1)=x+1-1=x$
Case $2: x=1$
$(g o f)(x)=g(f(x))=g(x+1)=1$
From case-1 and case-2, $(g o f)(x)=x, \forall x \in N$,
which is an identity function and, hence, it is onto.
which is an identity function and, hence, it is onto.