OFFSET
0,2
LINKS
A. Karttunen, Table of n, a(n) for n = 0..131071
EXAMPLE
For n=5, we get odd number 11 (2*5+1), and J(i,11) = 1,-1,1,1,1,-1,-1,-1,1,-1,0 when i ranges from 1 to 11, J(i,11) obtaining value -1 when i=2, 6, 7, 8 and 10, thus a(5)=33.
MATHEMATICA
Table[Total@ Select[Range[2n + 1], JacobiSymbol[#, 2n + 1]==-1 &], {n, 0, 100}] (* Indranil Ghosh, Jun 12 2017 *)
PROG
(MIT/GNU Scheme)
(define (A166405 n) (let ((w (A005408 n))) (let loop ((i 1) (s 0)) (cond ((= i w) s) (else (loop (1+ i) (+ s (if (= -1 (jacobi-symbol (1+ i) w)) (1+ i) 0))))))))
(Python)
from sympy import jacobi_symbol as J
def a(n): return sum(i for i in range(1, 2*n + 2) if J(i, 2*n + 1)==-1)
# Indranil Ghosh, Jun 12 2017
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Oct 21 2009
STATUS
approved