A finite non commutative ring of a specific cardinal All rings are supposed to have a unit element $1$ here.
Let $N\subset \mathbb N_{\geqslant 2}$ be the set such that $n\in N $ if, and only if, there does not exist a non commutative ring of cardinal $n$.
For instance, $16\notin N$ because $A=M_2(\mathbb F_2)$ is a non commutative ring and $\vert A\vert=2^4=16$.
In other words:
$$N=\{n\geqslant 2,\ \text{all rings with unit of cardinality $n$ are commutative}\}.$$
My conjecture is the following (I do not have a strong believe of its veracity though):

Conjecture. The set $N$ is equal to the set $\mathbb P$ of prime numbers.

What I did.


*

*We can start by proving that $\mathbb P\subset N$.


Let $(A,+,\times)$ be a ring of cardinal $p$ where $p$ is a prime number. Then $(A,+)$ is a group, and because $p$ is a prime number:
$$(A,+)\simeq \mathbb Z/p\mathbb Z.$$
So if $a\in A\setminus \{0\}$, then $a$ generate $(A,+)$, so there exists $n\in \mathbb Z$ (such that $p\nmid n$) such that $na=1$. Since we can look at $na$ in $\mathbb Z/p\mathbb Z$, $a$ is invertible in $A$, so $A$ is a field.
We can than conclude by Wedderburn theorem that $A$ is commutative, so $p\in N$.


*

*We can prove that $n\notin N$ where $n$ is of the form:


$$n=p^{km^2}$$
where $p$ is a prime number, $k\in \mathbb N_{\geqslant 1}$ and $m\in \mathbb N_{\geqslant 2}$.
We can look at $A=M_m(\mathbb F_{p^k})$ which is a non commutative finite ring under our hypotheses.


*

*We can prove that $n\notin N$ where $n$ is of the form:


$$n=p^{k\frac{m(m+1)}2}$$
where $p$ is a prime number, $k\in \mathbb N_{\geqslant 1}$ and $m\in \mathbb N_{\geqslant 2}$.
We can look at $A=T_m(\mathbb F_{p^k})$ the subset of upper triangular matrix of $M_m(\mathbb F_{p^k})$ which is a non commutative finite ring under our hypotheses.

My questions.


*

*I would tend to think that $4$ and $6$ are elements of $N$, but I am unable to find a counter-example.

*I wonder whether or not $p^q\in N$ where $p,q$ are prime numbers and $q>3$.

*More generally, I am interested of any kind of information about the set $N$.
 A: The set $N$ is exactly the set of $n$ such that there is no prime $p$ such that $p^3\mid n$.
First, for any prime $p$, the ring $R$ of $2\times 2$ upper-triangular matrices with entries in $\mathbb{F}_p$ is noncommutative and has $p^3$ elements.  If $n=p^3m$, then $A=\mathbb{Z}/m\times R$ is then a noncommutative ring with $n$ elements.
Conversely, suppose $n$ is not divisible by $p^3$ for any prime $p$ and $A$ is a ring with $n$ elements.  Say $n=p_1^{e_1}\cdots p_k^{e_k}$ for primes $p_1,\dots,p_k$, with $e_i=1$ or $2$ for each $i$.  Consider the additive subgroup $B\subseteq A$ generated by $1$.  Note that each $p_i$ must divide $|B|$: if $p_i$ does not divide $B$, then $p_i$ has a multiplicative inverse mod $|B|$, which means $p_i\cdot 1$ is a unit in $A$.  But since $p_i$ divides $|A|$, there is a nonzero $a\in A$ such that $p_i\cdot a=0$, so $p_i\cdot 1$ cannot be a unit.
So $|B|$ is divisible by $p_1\cdots p_k$.  The order of the quotient group $A/B$ is thus a factor of $p_1\cdots p_k$.  In particular, $|A/B|$ is squarefree, which means it is a cyclic group.  Let $a_0\in A$ be such that its image in $A/B$ generates $A/B$.
Now for any $a\in A$, there is an integer $m$ such that $a-ma_0\in B$, so there is an integer $\ell$ such that $a-ma_0=\ell\cdot 1$.  Thus every element of $A$ has the form $ma_0+\ell\cdot 1$ for some $m,\ell\in\mathbb{Z}$.  It follows that $A$ is commutative, since $a_0$ commutes with $1$ and so any element of the form $ma_0+\ell\cdot 1$ commutes with any other element of the same form.
