
EXAMPLE

a(n) = 1 for n = 1,2,3 due to the natural circular permutation (0,...,n).
a(4) = 1 due to the circular permutation (0,1,4,2,3).
a(5) = 5 due to the circular permutations (0,1,2,4,5,3), (0,1,4,2,3,5), (0,1,4,5,3,2), (0,2,1,4,5,3), (0,3,2,1,4,5).
a(6) = 9 due to the circular permutations
(0,1,2,4,5,3,6), (0,1,2,4,5,6,3), (0,1,4,2,3,5,6),
(0,1,4,2,3,6,5), (0,1,4,5,6,3,2), (0,2,1,4,5,3,6),
(0,2,1,4,5,6,3), (0,3,2,1,4,5,6), (0,5,4,1,2,3,6).
a(7) = 17 due to the circular permutations
(0,1,2,7,4,5,3,6), (0,1,2,7,4,5,6,3), (0,1,4,7,2,3,5,6),
(0,1,4,7,2,3,6,5), (0,1,7,2,4,5,3,6), (0,1,7,2,4,5,6,3),
(0,1,7,4,2,3,5,6), (0,1,7,4,2,3,6,5), (0,1,7,4,5,6,3,2),
(0,2,1,7,4,5,3,6), (0,2,1,7,4,5,6,3), (0,2,7,1,4,5,3,6),
(0,2,7,1,4,5,6,3), (0,3,2,1,7,4,5,6), (0,3,2,7,1,4,5,6),
(0,5,4,1,7,2,3,6), (0,5,4,7,1,2,3,6).


MATHEMATICA

(* A program to compute required circular permutations for n = 7. To get "undirected" circular permutations, we should identify a circular permutation with the one of the opposite direction; for example, (0, 6, 3, 5, 4, 7, 2, 1) is identical to (0, 1, 2, 7, 4, 5, 3, 6) if we ignore direction. Thus a(7) is half of the number of circular permutations yielded by this program. *)
p[i_, j_]:=PrimeQ[2*Abs[ij]+1]&&PrimeQ[2(i+j)+1]
V[i_]:=Part[Permutations[{1, 2, 3, 4, 5, 6, 7}], i]
m=0
Do[Do[If[p[If[j==0, 0, Part[V[i], j]], If[j<7, Part[V[i], j+1], 0]]==False, Goto[aa]], {j, 0, 7}]; m=m+1; Print[m, ":", " ", 0, " ", Part[V[i], 1], " ", Part[V[i], 2], " ", Part[V[i], 3], " ", Part[V[i], 4], " ", Part[V[i], 5], " ", Part[V[i], 6], " ", Part[V[i], 7]]; Label[aa]; Continue, {i, 1, 7!}]
