Solution (source code)

= Solution
{c}

Since $Ae_i=r_ie_i$, the <vector> $e_i$ is an <eigenvector> with nonzero <eigenvalue> $r_i$. The assumption $r_i\ne0$ also makes $r\ne0$, so the <kernel> has <dimension> $n-1$. Choose its <basis> $u_1,\ldots,u_{n-1}$.

The <vector> $e_i$ is outside this <kernel>. Hence $(u_1,\ldots,u_{n-1},e_i)$ is a <basis> of $\mathbb R^n$ consisting of <eigenvectors>, with corresponding <eigenvalues> $0,\ldots,0,r_i$. In that <basis>, $A$ is the <diagonal matrix>
$$
\boxed{\operatorname{diag}(0,\ldots,0,r_i).}
$$
This proves that $A$ is a <diagonalisable matrix>, including the case $n=1$.