<s>[INST] Evaluate $\int_0^1{\frac{u^{n+2}+u^n}{u+1}}\,du$ for $n\in\mathbb{N}$, $n\neq-1$ Background:
I got stuck in the question below because of a silly error.

Evaluate the integral using the substitution $u=\tan x$
$$\int^{\frac{1}{4}\pi}_0{(\tan^{n+2}x+\tan^{n}x)}\,dx$$

I realized that $du = \sec^2x\,dx$ and hence $du=\mathbf{(u+1)}\,dx$. The error being that $\sec^2x = u^2 +1$, NOT $u+1$.
If we proceed and use the erroneous expression $du = (u+1)\,dx$, we get:
$$\int_0^1{\frac{u^n(u^2+1)}{u+1}}\,du$$
Which is the question that I'm asking: how do you evaluate this integral?
And more generally, how can you evaluate an integral of the form:
$$\int{\frac{u^n}{u+a}\,du}$$
where $a\in\mathbb{Z}$
 [/INST] $$\frac{u^n}{u+a} = u^{n-1} - au^{n-2} + a^2u^{n-3} - \cdots + a^{n-2}u - a^{n-1} -\frac{a^n}{u+a} $$
So
\begin{align}
\int \frac{u^n}{u+a} du &= \int \left(u^{n-1} - au^{n-2} + a^2u^{n-3} - \cdots + a^{n-2}u - a^{n-1} -\frac{a^n}{u+a}\right) du\\
&= \frac{u^n}{n} - a \frac{u^{n-1}}{n-1} + a^2 \frac{u^{n-2}}{n-2} - \cdots + a^{n-2} \frac{u^2}{2} - a^{n-1}u - a^n \ln{|u+a|}\\
&= \sum_{m=0}^{n-1} (-1)^ma^m \frac{u^{n-m}}{n-m} - a^n\ln{|u+a|}.
\end{align}
</s>