OFFSET
0,3
COMMENTS
Note that this sequence is not equal to the sum of the quadratic residues of 2n+1 in range [1,2n+1], and thus NOT a bisection of A165898.
LINKS
A. Karttunen, Table of n, a(n) for n = 0..131071
Wikipedia, Jacobi symbol
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) getting value 1 when i=1, 3, 4, 5 and 9, thus a(5)=22.
MATHEMATICA
Table[Total[Flatten[Position[JacobiSymbol[Range[2n+1], 2n+1], 1]]], {n, 0, 50}] (* Harvey P. Dale, Jun 19 2013 *)
PROG
(MIT Scheme:) (define (A166100 n) (let ((w (A005408 n))) (let loop ((i 1) (s 1)) (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 13 2009. Erroneous name corrected Oct 20 2009.
STATUS
approved