So the proof for the reduction formula for [tan(x)]^n I found here, and it makes sense

But I did this and it is very close, but not the same formula, what's wrong?

$\displaystyle \int tan^nx dx = \int tan^n^-^2x *tan^2x dx $

$\displaystyle =\int tan^n^-^2x(sec^2x -1) dx $

$\displaystyle = \int tan^n^-^2x*sec^2x dx - \int tan^n^-^2x dx$

here I did an integration by parts of the first integral above:

$\displaystyle u= tan^n^-^2x,,,,,,,,,,,,,,,dv=sec^2xdx$

$\displaystyle du=(n-2)tan^n^-^3xdx,,,,,,v=tanx $

$\displaystyle uv-\int vdu $

$\displaystyle tan^n^-^1x-(n-2)\int tan^n^-^2xdx - \int tan^n^-^2xdx$

so I get

$\displaystyle \int tan^nx = tan^n^-^1x-(n-1)\int tan^n^-^2xdx $ Where's did I go wrong?