Task:
Input: DFA $M = (Z, Σ, δ, q_S, E)$
$T(M)$ := Language that $M$ accepts.
Question: Does $T(M)$ contain at least one word $w$ such that $|w| = n^2$ with $n \in \mathbb{N}$$ ?$
My attempt:
Since the language $\{w\in Σ^* \mid |w| = n^2 \} $is not regular. You cannot create DFA $M'$ which accepts this language and use it somehow.
If $M$ is finite (which is decidable) you can check each word so this is not a problem.
If $M$ is not finite there has to be a cycle from a productive state. I have drawn a couple simple DFAs and I have noticed that there is DFA's with cycles that don't contain such word $w$.
Then I tried to find the property of the cycle/DFA so that there has to be a $w$ with $|w| = n^2$ and noticed that the following equation has to be true: $$n^2 = d + ck$$ with $d$ being the distance from the initial state $q_s$ to an accepting state $q_e \in E$ and $c$ being the length of the cycle somewhere on the path from $q_s$ to $q_e$.
Therefore: $$\sqrt{d+ck} \in \mathbb{N}$$ However I don't know how to continue from here. Any help would be greatly appreciated!