We are told:
\[
I_0 + I_1 + 2I_2 + 2I_3 + 2I_4 + I_5 + I_6 = \sum_{k=1}^n \frac{\tan^k x}{k}
\]
Now compare term-wise with the RHS. The sum on the right has \( n \) terms from \( k = 1 \) to \( k = n \).
The presence of \( \frac{\tan^5 x}{5} \) means \( n = 5 \) is the last term on the right.
Hence, the correct value of \( n \) is \( \boxed{5} \).