OFFSET
1,1
COMMENTS
The term r*(r + 1)/2 is the triangular number A000217(r).
All safe primes q > 7 (A005385) are included. Proof (indirect): Assume a safe prime 7 < q = 2*p + 1 solves 5 <= r < q - 2, q - 2 == r (mod r*(r + 1)/2), q = 6*t - 1. This yields to a Sophie Germain prime (A005384) p = (1/4)*(1 + r)*(2 + r*t). But this is composite in all possible cases for r, t. QED.
The set {a(n)} is one of four disjunct classes of primes p >= 7 dependent on all cases of the two conditions p == [1 | 5] (mod 6) and if [at least one | not any] r in the range 5 <= r < p - 2 exists with p - 2 == r (mod r*(r + 1)/2).
MATHEMATICA
lst = {}; Do[p = Prime[n]; f = False;
If[5 == Mod[p, 6], f = True;
Do[If[r == Mod[p - 2, 1/2 r (1 + r)], f = False], {r, 5, p - 3}]];
If[f, lst = AppendTo[lst, p]], {n, 4, 500}]; lst
CROSSREFS
KEYWORD
nonn
AUTHOR
Ralf Steiner, Jun 26 2018
STATUS
approved