Is the existence of a right identity and right inverses a sufficient condition for $(G,*)$ to be a group? [duplicate]

I have come across an exercise that I cannot solve and honestly, to me, it doesn’t even seem true.

It goes like this:

Let $$G$$ be a non empty set and $$*$$ an associative operation on $$G$$ such that:

• $$\exists e\in G:\forall x\in G: x*e = x$$ (right identity)
• $$\forall x\in G: \exists y\in G: x*y = e$$ (right inverse)

Prove that $$(G,*)$$ is a group. (Hint: start by proving that $$g*g = g \implies g = e$$).

I tried to solve this in the following way:

$$g*g = g \implies (g*g)*r = g*r \implies g*(g*r) = e \implies g*e = e \implies g = e$$ where $$r$$ is a right inverse of g. We can actually see that the statements $$g*g = g$$ and $$g = e$$ are equivalent.

After this I tried to prove that the statements implied the existence of a left identity and its equality with $$e$$, but I had no success so far.

Hope you can help and thank you in advance.

• I suggest you to change the title to a clearer statement like "Is the existence of right inverses and a right identity sufficient for $G$ to be a group?" or something like that. edit: Thanks. I had already upvoted your question. – stressed out Jan 24 '19 at 12:56
• As a side note, $e_l$ (a left identity, if one exists) itself has a right inverse. This implies that $e_l = e$. – stressed out Jan 24 '19 at 13:01
• Thank you, I appreciate the help from both – Daàvid Jan 24 '19 at 13:15