Is $L:=\{a^k \mid k \text{ is prime}\}$ regular?
You don’t need any code. If S is any set of integers such that the difference between neighbouring elements becomes arbitrary large, then $\{a^k: k \in S\}$ is non-regular.