Let $R$ be an integral domain. Show that $U(R)$ has at most $n$ elements of order $n$, for every positive integer $n$. Also give an example of a commutative ring $R$ with identity which is not an integral domain for which this is not true.
My attempt: If $a$ is an element in $ U(R)$ and has order $n$, then $a^n=1$. I think that a possible way to do this in the case that $R$ is finite is by considering the polynomial $f(x)=x^n-1$ in $R[x]$, since in this case $R$ is a field, and thus we can ensure that $f(x)$ has at most $n$ roots. Since $a$ is a root of $f(x)$, the result hold. But, what about the case when $R$ is infinite?
On the other hand, in this question appears what would be a solution for the second part. It should be said that this does not completely answer my question, since here $R$ was considered directly as a field. Or at least I think so... Thanks in advance