I have a question regarding prime numbers. Specifically, I wonder if the following is true:
If $q$ is a prime and $w=(1+q+q^2)/3$ is an integer, then $w$ is composite iff $w$ has a prime divisor less than $\sqrt{w}$ and congruent to $1$ modulo $6$.
Edit: The problem appears in this paper.
As @HagenvonEitzen said in the comments $w$ is an integer only if $q\equiv 1\pmod{6}$. Let $q=6k+1$ then $$ w=\frac{q^3-1}{3(q-1)}=\frac{216k^3+108k^2+18k}{18k}=12k^2+6k+1=3k^2+(3k+1)^2 $$ So $w$ is the norm of an Eisenstein integer $W=(3k+1)+k\sqrt{-3}=a+b\omega\in \mathbb{Z}[\sqrt{-3}]$ with $a=2k+1,b=2k$.
Since $\mathbb{Z}[\sqrt{-3}]$ is Euclidean we can factor $W$ into Eisenstein primes. Since $(2k+1,2k)=1$ no rational prime can divide $W$. The other Eisenstein primes have $|z|^2=p$ where $p=3$ or $p\equiv 1\pmod{6}$ is a rational prime. $3\nmid w$ so $w$ is the product of primes congruent to 1 modulo 6.
Either $w$ is prime, $w=p^2$ for some prime $p$, or $w=pv$ is composite with some prime factor $1<p<\sqrt{w}$. In fact if $q=313$ then $w=181^2$, so each case is possible and the claim as stated is not quite correct.