I have the following question:
Let $S$ be a semigroup with finite number of elements. Suppose that the two cancellation laws hold in $S$; that is, if either $ab = ac$ or $ba = ca$, then $b = c$. Firstly, show that for each $a \in S$ there exist a positive integer $n(a)$ such that $a^{n(a)+1}=a$. Also show that if $a,b \in S$, then $a^{n(a)}=b^{n(b)}$.
I attempted the first part by using the definition of the order of $a$, "$o(a)=n$", where $n \in \mathbb{N}$, and then letting $n=n(a)$, I used $a^n=e$, where $e$ is the identity element. Then multiplied with $a$ on the right. But I realised this is not correct because $S$ is only a semigroup.
The second part I did similarly, with $n,m \in \mathbb{N}$, where $n(a)=n$ and $m=n(b)$ to end up with $a^n=e=a^m$, but this is obviously then also not correct.
How can I show the first and second part by using the finiteness and cancellation laws?
For the first part, suppose that there was no such positive integer $n(a)$ then $a^n\neq a^m$ for any positive integers $n\neq m$ (else, assuming $n>m$ we could use cancellation to obtain $a^{n-m+1} = a$). This would contradict the fact that $S$ has a finite number of elements. For the second part $$a\cdot a^{n(a)} = a\implies a\cdot a^{n(a)}\cdot b = a\cdot b = a\cdot b^{n(b)}\cdot b$$. Then using left and right cancellation we obtain $a^{n(a)} = b^{n(b)}$.