Establish a reduction formula for the following integrals.

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

$\displaystyle \int \sec^n x dx$

I figure that both are similar, and that if I can figure out one i should be able to do the other.

The examples i was given would give the method

$\displaystyle \int\tan^n x dx=\int\tan x\tan^{n-1} x dx$ and then use integration by parts, but I'm not sure about this one.

I tried

$\displaystyle \int\tan^n x dx=\int\tan^2 x\tan^{n-2} x dx$

$\displaystyle =\tan^{n-2}x(\tan x -x)-(n-2)\int(\sec^2 x \tan^{n-3} x)(\tan x -x)$

But i could not work it out to the answer which is

$\displaystyle (n-1)(I_n+I_{n-2})=\tan^{n-1} x$, $\displaystyle I_n=\int\tan^n x dx$ and $\displaystyle I_{n-2}=\int\tan^{n-2} x dx$

Thanks!