# Is a non-commutative, invertible monoid closed under an associative binary operation?

I've been given this question that's been puzzling me for a while:

$M$ is a monoid with identity element denoted by $e$.

$U(M)$ is the set of all invertible elements of $M$.

Suppose that $M$ is not commutative.

Let $a, b \in M$. If $ab \in U(M)$, then is it necessarily the case that $a \in U(M)$?

Hint: Consider the monoid of the set of all functions from positive integers into itself, equipped with the binary operation of composition of functions, together with the element $b \in M$ that is defined as follows: $b(n)=n+1 \ \forall n \in \Bbb N$.

I believe that it's not always necessarily the case and I need to provide a counter example. I'm attempting to find a function $a(n) \circ b(n)$ is equal to an invertible function. However the invertible function that I can think of is one as the function has a domain and co-domain of positive integers.

Is this the right approach? I'm not sure where to go from here.

Let $a(1) := 1$ and $a(n) := n - 1$ for $n > 1$. Then $a$ has no inverse (since $a(1) = a(2)$) but $a \circ b$ is the identity.
Consider the function $a:\Bbb N \to \Bbb N$ given by:
$a(n) = n-1$ for $n > 0$
$a(0) = 0$.
What is $a \circ b$?
EDIT: as the other answer shows this can be modified to give a similar $a: \Bbb Z^{+} \to \Bbb Z^{+}$ (Both $\Bbb N^{\Bbb N}$ and $(\Bbb Z^{+})^{\Bbb Z^{+}}$ form monoids under composition).