Let #n=2k+1#, then:
#int cot^nxdx = int cot^(2k+1)xdx = int (cot^2x)^k cotxdx = I#
#cot^2x=t => 2cotx(-csc^2x) dx = dt#
#-2cotx(1+cot^2x) dx = dt#
#cotxdx=-1/2 dt/(t+1)#
#I = -1/2 int t^k/(t+1) dt#
#t^k/(t+1) = sum_(i=0)^(k-1) (-1)^i t^(k-i-1) + (-1)^k/(t+1)#
#I = -1/2 int (sum_(i=0)^(k-1) (-1)^i t^(k-i-1) + (-1)^k/(t+1)) dt#
#I = -1/2 (sum_(i=0)^(k-1) (-1)^i int t^(k-i-1)dt + (-1)^k int dt/(t+1))#
#I = -1/2 (sum_(i=0)^(k-1) (-1)^i t^(k-i)/(k-i) + (-1)^k ln|t+1|)#
#I = -1/2 (sum_(i=0)^(k-1) (-1)^i (cot^2x)^(k-i)/(k-i) + (-1)^k ln|csc^2x|)#
Let #n=2k#, then:
#int cot^nxdx = int cot^(2k)xdx = int (cotx)^(2k) dx = I#
#cotx=t => -csc^2xdx=dt =>dx=-dt/(t^2+1)#
#I = -int t^(2k)/(t^2+1)dt#
#t^(2k)/(t^2+1) = sum_(i=0)^(k-1) (-1)^i t^(2(k-i-1)) + (-1)^k/(t^2+1)#
#I = -int (sum_(i=0)^(k-1) (-1)^i t^(2(k-i-1)) + (-1)^k/(t^2+1)) dt#
#I = -(sum_(i=0)^(k-1) (-1)^i int t^(2(k-i-1)) dt + (-1)^k int dt/(t^2+1))#
#I = -(sum_(i=0)^(k-1) (-1)^i t^(2(k-i-1)+1)/(2(k-i-1)+1) + (-1)^k arctant)#
#I = -(sum_(i=0)^(k-1) (-1)^i (cotx)^(2(k-i)-1)/(2(k-i)-1) + (-1)^k arctan(cotx))#
#I = -(sum_(i=0)^(k-1) (-1)^i (cotx)^(2(k-i)-1)/(2(k-i)-1) + (-1)^k (x-pi/2))#