This loops here calculate Bernoulli number which is further used to get the coefficient in the expansion of tan x
B = 0 ; NEW_LINE Bn = 2 * i ; NEW_LINE for k in range ( Bn + 1 ) : NEW_LINE INDENT temp = 0 ; NEW_LINE for r in range ( 0 , k + 1 ) : NEW_LINE INDENT temp = temp + pow ( - 1 , r ) * fac ( k ) * pow ( r , Bn ) / ( fac ( r ) * fac ( k - r ) ) ; NEW_LINE DEDENT B = B + temp / ( ( k + 1 ) ) ; NEW_LINE DEDENT sum = sum + pow ( - 4 , i ) * ( 1 - pow ( 4 , i ) ) * B * pow ( x , 2 * i - 1 ) / fac ( 2 * i ) ; NEW_LINE