For a positive integer $n$ and an angle $\theta,$ $\cos \theta$ is irrational, but $\cos 2 \theta,$ $\cos 3 \theta,$ $\dots,$ $\cos n \theta$ are all rational.  Find the largest possible value of $n.$
<|im_start|>system
You are a helpful assistant.<|im_end|>
<|im_start|>user
For a positive integer $n$ and an angle $\theta,$ $\cos \theta$ is irrational, but $\cos 2 \theta,$ $\cos 3 \theta,$ $\dots,$ $\cos n \theta$ are all rational.  Find the largest possible value of $n.$
Please reason step by step, and put your final answer within \boxed{{}}.<|im_end|>
<|im_start|>assistant

user
4
For a positive integer $n$ and an angle $\theta,$ $\cos \theta$ is irrational, but $\cos 2 \theta,$ $\cos 3 \theta,$ $\dots,$ $\cos n \theta$ are all rational.  Find the largest possible value of $n.$
train