Factorization is the most fundamental way to determine if a number $n$ is prime or composite. Yet, this approach becomes impracticable when considering large values of $n$, a difficulty that is exploited by cryptographic protocols. We propose an alternative method to decide the primality of a natural number, that is based on the analysis of the evolution of the linear entanglement entropy. Specifically, we show that a singular behavior in the amplitudes of the Fourier series of this entropy is associated with prime numbers. We also discuss how this idea could be experimentally implemented and examine possible connections between our results and the zeros of the Riemann zeta function.