cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A165909 a(n) is the sum of the quadratic residues of n.

This page as a plain text file.
%I A165909 #54 Feb 28 2021 09:53:47
%S A165909 0,1,1,1,5,8,7,5,12,25,22,14,39,42,30,14,68,60,76,35,70,110,92,42,125,
%T A165909 169,126,84,203,150,186,72,165,289,175,96,333,342,208,135,410,308,430,
%U A165909 198,225,460,423,124,490,525,408,299,689,549,385,252,532,841,767,270
%N A165909 a(n) is the sum of the quadratic residues of n.
%C A165909 The table below shows n, the number of nonzero quadratic residues (QRs) of n (A105612), the sum of the QRs of n and the nonzero QRs of n (A046071) for n = 1..10.
%C A165909 ..n..num QNRs..sum QNRs.........QNRs
%C A165909 ..1.........0.........0
%C A165909 ..2.........1.........1.........1
%C A165909 ..3.........1.........1.........1
%C A165909 ..4.........1.........1.........1
%C A165909 ..5.........2.........5.........1..4
%C A165909 ..6.........3.........8.........1..3..4
%C A165909 ..7.........3.........7.........1..2..4
%C A165909 ..8.........2.........5.........1..4
%C A165909 ..9.........3........12.........1..4..7
%C A165909 .10.........5........25.........1..4..5..6..9
%C A165909 When p is prime >= 5, a(p) is a multiple of p by a variant of Wolstenholme's theorem (see A076409 and A076410). _Robert Israel_ remarks that we don't need Wolstenholme, just the fact that Sum_{x=1..p-1} x^2 = p*(2*p-1)*(p-1)/6. - _Bernard Schott_, Mar 13 2019
%D A165909 G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers. 4th ed., Oxford Univ. Press, 1960, pp. 88-90.
%H A165909 Alois P. Heinz, <a href="/A165909/b165909.txt">Table of n, a(n) for n = 1..10000</a> (first 1000 terms from C. H. Gribble)
%t A165909 residueQ[n_, k_] := Length[Select[Range[Floor[k/2]], PowerMod[#, 2, k] == n&, 1]] == 1;
%t A165909 a[n_] := Select[Range[n-1], residueQ[#, n]&] // Total;
%t A165909 Array[a, 60] (* _Jean-François Alcover_, Mar 13 2019 *)
%o A165909 (Haskell)
%o A165909 import Data.List (nub)
%o A165909 a165909 n = sum $ nub $ map (`mod` n) $
%o A165909                         take (fromInteger n) $ tail a000290_list
%o A165909 -- _Reinhard Zumkeller_, Aug 01 2012
%o A165909 (PARI) a(n) = sum(k=0, n-1, k*issquare(Mod(k,n))); \\ _Michel Marcus_, Mar 13 2019
%Y A165909 Row sums of A046071 and of A096008.
%Y A165909 Cf. A000290, A076409, A076410.
%K A165909 nonn
%O A165909 1,5
%A A165909 _Christopher Hunt Gribble_, Sep 30 2009