How to factor $x^k -1$? Is there any way to find the degrees of the irreducible factors of a polynomial $x^k - 1$ over the field

*

*$\Bbb F_q $, and

*over $\Bbb Q$, in general,

for any k? The reason why I am asking this is because I have been trying to factor them, and of course, I have been able to do it when the $k$ is given but had never found a way to do it in general.
Edit 1: I just wanted to clarify that this exercise was suggested, when I was learning field theory and Galois theory, and we were asked to do it in as much generality as possible. Even though I tried it for quite sometime, I wasn't able to progress beyond specific cases. Now that the course is over, I realised that I perhaps haven't solved this completely even now, and hence the question.
Edit 2: Also, the question I mentioned doesn't need the polynomial to be factored, just to find the degrees of irreducible factors. I have hence edited the question. Sorry for the confusion.
 A: Let $K$ be a field and $n$ be a positive integer. An element $\zeta$ in the algebraic closure of $K$ satisfying $\alpha^n=1$ but $\alpha^m\ne1$ for $0<m<n$ is called an $n$-th primitive root of unity, and the $n$-th cyclotomic polynomial is defined to be
$$\Phi_n(x)=\prod_i(x-\zeta^i),$$
where $1\le i\le n$ and $\gcd(i,n)=1$. In fact, $\Phi_n(x)$ is a polynomial over $K$. It is not hard to see
$$x^k-1=\prod_{n\mid k}\Phi_n(x).$$
Then it remains to factor the cyclotomic polynomials. For the finite field $\mathbb F_q$ and $\mathbb Q$, we have two results as follows.

Theorem. If $\gcd(q, n)=1$, then $\Phi_n$ factors into $\phi(n)/d$ distinct monic irreducible polynomials in $\mathbb F_q[x]$ of the same degree $d$, where $\phi$ is the Euler function and $d$ is the least positive integer such that $q^d\equiv1\pmod n$.


Theorem. Cyclotomic polynomials over $\mathbb Q$ are irreducible.

A: For the field $\mathbb{Q} $, the highest degree of irreducible factor(which is a cyclotomic polynomial) of $ x^k - 1$ is $\phi(k)$, here $\phi $ is Euler-$\phi $ function.
For finite field $\mathbb{F}_{q} $, this can't be applied !
For example , $ x^3 - 1 $ has two irreducible factors $(x-1)$ ,$( x^2 + x + 1 ) $ over the field $\mathbb{Q} $ , But over the field $\mathbb{F}_{3} $, $( x^2 + x + 1 ) $ is not irreducible!
