a) Give an example of a function from $\Bbb{Z}^+$ to $\Bbb{Z}^+$ that is neither one-to-one nor onto.
b) Let $g:A\to B$ and $f : B \to C$ be functions. Let $f\circ g$ be onto. Are both $f$ and $g$ necessarily onto?
I was thinking for
a) $f(n) = 1$
I clearly see that this is not one to one, since there is no unique codomain for each input. but im not sure about onto..
Wouldn't all values point to 1 which would make it onto? since the codomain is 1? or would it? im confused if there is no x value in the function.
For a) the function would not be one to one. That is correct.
It appears you have conflated the codomain and the range of a function.
The codomain of $f$ is $\Bbb{Z}^+.$ The range of $f$ is $\{1\}\ne \Bbb{Z}^+.$