building NFA for { a^p; p is a prime number, m is a fixed number and m >p >0 }
Your DFA has states $S_0$ to $S_m$ and E. You start at state $S_0$.
Any state transitions to E if the next input symbol is not a. States $S_m$ and E transition to state E on any input; state $S_i$ for 0 ≤ i &lt; m goes to state $S_{i+1}$ on input a.
$S_i$ is an accepting state if and only if i is a prime. All other states are non-accepting.