De Rham cohomology of $\mathbb{RP}^{n}$

The involution $i:S^n\to S^n:x\mapsto -x$ induces a decomposition $\Omega^n(S^{n})=\Omega^n_+(S^{n}) \oplus \Omega^n_-(S^{n})$ where $\Omega^n_\pm(S^{n}) $ consists of the differential forms satisfying $i^*\omega=\pm \omega$.
This yields a decomposition $H^n(S^{n})=H^n_+(S^{n}) \oplus H^n_-(S^{n})\cong \mathbb R$

On the other hand the quotient map $\phi:S^{n}\to\mathbb{RP}^{n}$ induces an isomorphism $\phi^*:\Omega^n(\mathbb P^{n})\stackrel {\cong}{\to }\Omega^n_+(S^{n})$ and then an isomorphism $\phi^*:H^n(\mathbb P^{n})\stackrel {\cong}{\to }H^n_+(S^{n})$.

Finally there remains to notice that the the canonical generator $[\omega_0]\in H^n(S^{n})=\mathbb R [\omega_0]$ is in $H^n_+(S^{n})$ or $H^n_-(S^{n})$ according as $n$ is odd or even, since $i^*(\omega_0)=(-1)^{n+1}\omega_0$.
We can thus conclude that $H^n(\mathbb P^{n})=\mathbb R$ for $n$ odd and $H^n(\mathbb P^{n})=0$ for $n$ even.

Reminder
The form $\omega_0\in \Omega^n(S^n)$ is defined by $$\omega_0(s)(v_1,\cdots,v_n)=det(s,v_1,\cdots,v_n)$$

Explanation of this formula: The point $s$ lies on the sphere which is itself embedded in $\mathbb R^{n+1}$, i.e. $s\in S^n\subset \mathbb R^{n+1}$.
The value $\omega_0(s) $ at $s$ of $\omega_0$ is an $n$-multilinear form on $T_s(S^n)\subset T_s(\mathbb R^{n+1})=\mathbb R^{n+1}$ and $T_s(S^n)$ consists of those $v\in \mathbb R^{n+1}$ orthogonal to the vector $s$, i.e. $T_s(S^n)=s^\perp$.
The formula says that the value of that multilinear function $\omega_0(s) $ on a $n$-tuple of vectors $v_1,\cdots,v_n\in T_s(S^n)$is the determinant of the matrix of the $n+1$ vectors $s,v_1,\cdots,v_n$ seen as column vectors in $\mathbb R^{n+1}$.