%I #22 Jul 20 2020 06:41:54
%S 3,7,11,23,31,47,59,71,79,83,103,131,151,167,191,199,239,251,263,271,
%T 311,359,383,419,431,439,479,503,563,599,607,647,659,719,743,751,839,
%U 863,887,911,919,971,983,991,1031,1039,1063,1091,1103,1151
%N Odd primes p for which all sums Sum_{i=1..u} L(i/p) (with u ranging from 1 to (p-1)) are nonnegative, where L(i/p) is Legendre symbol of i and p, defined to be 1 if i is a quadratic residue (mod p) and -1 if i is a quadratic non-residue (mod p).
%C All 4k+3 primes whose Legendre-vector (cf. A055094) forms a valid Dyck-path (cf. A014486).
%H T. D. Noe, <a href="/A095102/b095102.txt">Table of n, a(n) for n=1..1000</a>
%H Peter Borwein, Stephen K.K. Choi and Michael Coons, <a href="http://arxiv.org/abs/0809.1691">Completely multiplicative functions taking values in {-1,1}</a>, arXiv:0809.1691 [math.NT], 2008.
%H A. Karttunen and J. Moyer, <a href="/A095062/a095062.c.txt">C-program for computing the initial terms of this sequence</a>
%F a(n) = 4*A095272(n) + 3.
%t isMotzkin[n_, k_] := Module[{s = 0, r = True}, Do[s += JacobiSymbol[i, n]; If[s < 0, r = False; Break[]], {i, 1, k}]; r]; A095102[max_] := Select[ Range[3, max, 4], PrimeQ[#] && isMotzkin[#, Quotient[#, 2]]&]; A095102[1151] (* _Jean-François Alcover_, Feb 16 2018, after _Peter Luschny_ *)
%o (Sage)
%o def A095102_list(n) :
%o def is_Motzkin(n, k):
%o s = 0
%o for i in (1..k):
%o s += jacobi_symbol(i, n)
%o if s < 0: return False
%o return True
%o P = filter(is_prime, range(3, n+1, 4))
%o return filter(lambda m: is_Motzkin(m, m//2), P)
%o A095102_list(1151) # _Peter Luschny_, Aug 09 2012
%o (PARI) isok(m) = {if(!isprime(m-(m<3)), return(0)); my(s=0); for(i=1, m-1, if((s+=kronecker(i, m))<0, return(0))); 1; } \\ _Jinyuan Wang_, Jul 20 2020
%Y Intersection of A000040 and A095100. Subset of A080114 (see comments there). Complement of A095103 in A002145.
%Y Cf. A095092.
%K nonn
%O 1,1
%A _Antti Karttunen_, Jun 01 2004