OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
Christian Aebi, Grant Cairns, Sums of Quadratic residues and nonresidues, arXiv:1512.00896 [math.NT], 2015.
FORMULA
a(n) = Sum_{k=1..(A002145(n)-1)/2} (-k^2) mod A002145(n). - J. M. Bergot and Robert Israel, Nov 09 2020
MAPLE
with(numtheory):
a:=[]; m:=[]; d:=[];
for i1 from 1 to 200 do
p:=ithprime(i1);
if (p mod 4) = 3 then
sp:=0; sm:=0;
for j from 1 to p-1 do
if legendre(j, p)=1 then sp:=sp+j; else sm:=sm+j; fi; od;
a:=[op(a), sp]; m:=[op(m), sm]; d:=[op(d), sm-sp];
fi;
od:
# Alternative:
f:= p -> add(-k^2 mod p, k=1..(p-1)/2)::
map(f, select(isprime, [seq(p, p=3..1000, 4)])); # Robert Israel, Nov 09 2020
MATHEMATICA
f[p_] := Total[Range[p-1] ~Complement~ Table[Mod[k^2, p], {k, (p-1)/2}] ]; f /@ Select[Range[3, 1000, 4], PrimeQ] (* Jean-François Alcover, Feb 16 2018, after Robert Israel *)
PROG
(PARI) lista(nn) = forprime(p=2, nn, if(p%4==3, print1(sum(k=1, p-1, if (!issquare(Mod(k, p)), k)), ", "))); \\ Michel Marcus, Nov 09 2020
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Feb 20 2017
STATUS
approved