Endomorphism with rank $r$ annihilates degree $r+1$ polynomial 
Let $f$ be a linear transformation of $\mathbb R^n\to \mathbb R^n$ that has rank $r$.
Prove the existence of a degree $r+1$ polynomial that annihilates $f$

I have a proof : consider $g$ which is $f$ restricted to $Im(f)$. Then $\chi_g=\sum_0^ra_k X^k$ which has degree $r$ annihilates g.
Thus, $\forall x\in \mathbb R^n, 0= \sum_0^r a_kg^k(f(x)) = \sum_0^r a_kf^{k+1}(x)$.
Therefore $ \sum_0^r a_kX^{k+1}$ is what we were looking for. 
 A: Let me generalize your claim:

Theorem 1. Let $\mathbb{K}$ be a field. Let $N$ be a $\mathbb{K}$-vector
  space. Let $r$ be a nonnegative integer. Let $f:N\rightarrow N$ be an
  endomorphism of $N$ that has rank $r$ (that is, the vector space $f\left(
N\right)  $ is $r$-dimensional). Then, there exists a polynomial
  $p\in\mathbb{K}\left[  X\right]  $ such that $\deg p=r+1$ and $p\left(
f\right)  =0$.

To prove this, I generalize a little bit further, replacing the field
$\mathbb{K}$ by a commutative ring. If this generality feels unnecessary to
you, you can just replace "commutative ring" back by "field", and "$M$ is
finitely generated and free" by "$M$ is finite-dimensional" in the following
theorem; I don't actually need this generality.

Theorem 2. Let $\mathbb{K}$ be a commutative ring. Let $M$ and $N$ be two
  $\mathbb{K}$-modules such that $M$ is finitely generated and free. Let
  $u:M\rightarrow N$ and $v:N\rightarrow M$ be two $\mathbb{K}$-linear maps. Let
  $\chi_{vu}$ be the characteristic polynomial of the endomorphism $vu$ of the
  $\mathbb{K}$-module $M$. Then, $v\chi_{vu}\left(  uv\right)  =0$.

Here, we are writing the composition of maps as multiplication (so, in
particular, "$vu$" means "$v\circ u$").
The proof of Theorem 2 relies on the following simple fact:

Lemma 3. Let $M$ and $N$ be two sets. Let $u:M\rightarrow N$ and
  $v:N\rightarrow M$ be any two maps. Then, $v\left(  uv\right)  ^{i}=\left(
vu\right)  ^{i}v$ for every nonnegative integer $i$.

Proof of Lemma 3. Both $v\left(  uv\right)  ^{i}$ and $\left(  vu\right)
^{i}v$ are clearly equal to the product $vuvuvu\cdots vuv$ of $2i+1$ factors,
which alternate between $v$ and $u$. (Alternatively, if this proof is too
sloppy for you, you can straightforwardly prove Lemma 3 by induction on $i$.)
$\blacksquare$
Proof of Theorem 2. The Cayley-Hamilton theorem (over commutative rings)
says that if $U$ is any finitely generated free $\mathbb{K}$-module, and if
$g$ is any endomorphism of $U$, then $\chi_{g}\left(  g\right)  =0$ (where
$\chi_{g}$ denotes the characteristic polynomial of $g$). Applying this to
$U=M$ and $g=vu$, we obtain $\chi_{vu}\left(  vu\right)  =0$. Now, let us
write the polynomial $\chi_{vu}$ in the form $\chi_{vu}=\sum_{i=0}^{m}
a_{i}X^{i}$ with coefficients $a_{0},a_{1},\ldots,a_{m}\in\mathbb{K}$ (where,
of course, we denote the indeterminate by $X$). From $\chi_{vu}=\sum_{i=0}
^{m}a_{i}X^{i}$, we obtain $\chi_{vu}\left(  vu\right)  =\sum_{i=0}^{m}
a_{i}\left(  vu\right)  ^{i}$. Comparing this with $\chi_{vu}\left(
vu\right)  =0$, we obtain $\sum_{i=0}^{m}a_{i}\left(  vu\right)  ^{i}=0$. But
from $\chi_{vu}=\sum_{i=0}^{m}a_{i}X^{i}$, we also obtain $\chi_{vu}\left(
uv\right)  =\sum_{i=0}^{m}a_{i}\left(  uv\right)  ^{i}$, so that
\begin{align}
v\chi_{vu}\left(  uv\right)  =v\sum_{i=0}^{m}a_{i}\left(  uv\right)  ^{i}
=\sum_{i=0}^{m}a_{i}\underbrace{v\left(  uv\right)  ^{i}}_{\substack{=\left(
vu\right)  ^{i}v\\\text{(by Lemma 3)}}}=\underbrace{\sum_{i=0}^{m}a_{i}\left(
vu\right)  ^{i}}_{=0}v=0.
\end{align}
This proves Theorem 2. $\blacksquare$
Proof of Theorem 1. Let $M$ denote the $\mathbb{K}$-vector space $f\left(
N\right)  $. This vector space $M$ is $r$-dimensional (since $f$ has rank
$r$), and thus is a finitely generated and free $\mathbb{K}$-module. Let
$v:N\rightarrow M$ be the $\mathbb{K}$-linear map sending each $n\in N$ to
$f\left(  n\right)  $. Let $u:M\rightarrow N$ be the canonical inclusion map
(since $M\subseteq N$). Then, clearly, $f=uv$. Meanwhile, $vu$ is an
endomorphism of the $r$-dimensional $\mathbb{K}$-vector space $M$, and thus
its characteristic polynomial $\chi_{vu}\in\mathbb{K}\left[  X\right]  $ has
degree $r$. Hence, the product $X\chi_{vu}\in\mathbb{K}\left[  X\right]  $ has
degree $r+1$. That is, $\deg\left(  X\chi_{vu}\right)  =r+1$. Now,
\begin{align*}
\left(  X\chi_{vu}\right)  \left(  f\right)   &  =f\chi_{vu}\left(  f\right)
=u\underbrace{v\chi_{vu}\left(  uv\right)  }_{\substack{=0\\\text{(by Theorem
2)}}}\qquad\left(  \text{since }f=uv\right)  \\
&  =0.
\end{align*}
Hence, there exists a polynomial $p\in\mathbb{K}\left[  X\right]  $ such that
$\deg p=r+1$ and $p\left(  f\right)  =0$ (namely, $p=X\chi_{vu}$). This proves
Theorem 1. $\blacksquare$
A: Let $A \in \mathbb{R}^{n \times n}$ be a matrix representing $f$ with respect to some basis of $\mathbb{R}^n$. Then, $\operatorname{rank} A = \operatorname{rank} f = r$, and we have to prove that there exists a polynomial of degree $r + 1$ that annihilates $A$ (because the very same polynomial will then annihilate $f$). It clearly suffices to show that the minimal polynomial of $A$ has degree $\leq r+1$.
If $A$ is invertible, this is obvious (since the minimal polynomial of $A$ has degree $\leq n = r \leq r+1$).
Let $m_A(x) = x^{r_1}(x-\lambda_2)^{r_2}\cdots (x-\lambda_k)^{r_k}$ be the minimal polynomial of $A$, with $\lambda_1 = 0$.
Recall that $r_i$ is precisely the size of the largest $\lambda_i$-block in the Jordan form of $A$. Also notice that nullity of $A$ is the number of all $0$-blocks.
Since the size of each Jordan block is $\ge 1$, we get
\begin{align}\text{size of largest $0$-block} &\le (\text{size of largest $0$-block}) + \sum_{i=2}^{\text{number of $0$-blocks}} \overbrace{(\text{size of $i$-th $0$-block}-1)}^{\ge 0}\\
&= \sum_{i=1}^{\text{number of $0$-blocks}} (\text{size of $i$-th $0$-block}) - ((\text{number of $0$-blocks})-1)\\
&= (\text{size of all $0$-blocks}) - (\text{number of $0$-blocks})+1
\end{align}
Therefore
\begin{align}
\deg m_A &= \sum_{i=1}^k r_i \\
&= (\text{size of largest $0$-block}) + \sum_{i=2}^k(\text{size of largest $\lambda_i$-block})\\
&\le (\text{size of all $0$-blocks}) - (\text{number of $0$-blocks}) +1 + \sum_{i=2}^k(\text{size of all $\lambda_i$-blocks})\\
&= (\text{size of Jordan form of }A) - (\text{number of $0$-blocks})+1\\
&= n-\operatorname{null}A+1\\
&= \operatorname{rank}(A)+1
\end{align}
A: Let $(e_1,\ldots,e_{n-r})$ a basis of $\ker f$ and we complete it on $(e_1,\ldots,e_n)$ a basis of $\Bbb R^n$. Let $V=\operatorname{span}(e_{n-r+1},\ldots, e_n)$ and the endomorphism $g$ the restriction of $f$ on $V$: $g\colon V\rightarrow \operatorname{im}(f)$ so the characteristic polynomial $\chi_g$ of $g$ has the degree $r=\dim V$ and it annihilates $g$ hence the polynomial 
$$P(x)=x\chi_g(x)$$
has the degree $r+1$ and it annihilates $f$. In fact, let $x=x_1+x_2$ where $x_1\in\ker f$ and $x_2\in V$ then (notice that $f$ and $\chi_g(f)$ commute)
$$f(\chi_g(f)(x))=\chi_g(f)(f(x))=\chi_g(f)(f(x_2))=f(\chi_g(f)(x_2))=f(0)=0$$
