OFFSET
1,1
LINKS
T. D. Noe, Table of n, a(n) for n=1..1000
Peter Borwein, Stephen K.K. Choi and Michael Coons, Completely multiplicative functions taking values in {-1,1}, arXiv:0809.1691 [math.NT], 2008.
A. Karttunen and J. Moyer, C-program for computing the initial terms of this sequence
FORMULA
a(n) = 4*A095272(n) + 3.
MATHEMATICA
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 *)
PROG
(Sage)
def A095102_list(n) :
def is_Motzkin(n, k):
s = 0
for i in (1..k):
s += jacobi_symbol(i, n)
if s < 0: return False
return True
P = filter(is_prime, range(3, n+1, 4))
return filter(lambda m: is_Motzkin(m, m//2), P)
A095102_list(1151) # Peter Luschny, Aug 09 2012
(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
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Jun 01 2004
STATUS
approved