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.

Showing 1-10 of 18 results. Next

A076409 Sum of the quadratic residues of prime(n).

Original entry on oeis.org

1, 1, 5, 7, 22, 39, 68, 76, 92, 203, 186, 333, 410, 430, 423, 689, 767, 915, 1072, 994, 1314, 1343, 1577, 1958, 2328, 2525, 2369, 2675, 2943, 3164, 3683, 3930, 4658, 4587, 5513, 5134, 6123, 6520, 6012, 7439, 7518, 8145, 7831, 9264, 9653, 8955, 10761, 11596
Offset: 1

Views

Author

R. K. Guy, Oct 08 2002

Keywords

Comments

Row sums of A063987. - R. J. Mathar, Jan 08 2015
prime(n) divides a(n) for n > 2. This is implied by a variant of Wolstenholme's theorem (see Hardy & Wright reference). - Isaac Saffold, Jun 21 2018

Examples

			If n = 3, then p = 5 and a(3) = 1 + 4 = 5. If n = 4, then p = 7 and a(4) = 1 + 4 + 2 = 7. If n = 5, then p = 11 and a(5) = 1 + 4 + 9 + 5 + 3 = 22. - _Michael Somos_, Jul 01 2018
		

References

  • G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers. 4th ed., Oxford Univ. Press, 1960, p. 88-90.
  • Kenneth A. Ribet, Modular forms and Diophantine questions, Challenges for the 21st century (Singapore 2000), 162-182; World Sci. Publishing, River Edge NJ 2001; Math. Rev. 2002i:11030.

Crossrefs

Cf. A076410.
Sums of residues, nonresidues, and their differences, for p == 1 mod 4, p == 3 mod 4, and all p: A171555; A282035, A282036, A282037; A076409, A125615, A282038.

Programs

  • Maple
    A076409 := proc(n)
      local a,p,i ;
      p := ithprime(n) ;
      a := 0 ;
      for i from 1 to p-1 do
        if numtheory[legendre](i,p) = 1 then
           a := a+i ;
        end if;
      end do;
      a ;
    end proc: # R. J. Mathar, Feb 26 2011
  • Mathematica
    Join[{1,1}, Table[ Apply[ Plus, Flatten[ Position[ Table[ JacobiSymbol[i, Prime[n]], {i, 1, Prime[n] - 1}], 1]]], {n, 3, 48}]]
    Join[{1}, Table[p=Prime[n]; If[Mod[p,4]==1, p(p-1)/4, Sum[PowerMod[k,2, p],{k,p/2}]], {n,2,1000}]] (* Zak Seidov, Nov 02 2011 *)
    a[ n_] := If[ n < 3, Boole[n > 0], With[{p = Prime[n]}, Sum[ Mod[k^2, p], {k, (p - 1)/2}]]]; (* Michael Somos, Jul 01 2018 *)
  • PARI
    a(n,p=prime(n))=if(p<5,return(1)); if(k%4==1, return(p\4*p)); sum(k=1,p-1,k^2%p) \\ Charles R Greathouse IV, Feb 21 2017

Formula

If prime(n) = 4k+1 then a(n) = k*(4k+1).
For n>2 if prime(n) = 4k+3 then a(n) = (k - b)*(4k+3) where b = (h(-p) - 1) / 2; h(-p) = A002143. For instance. If n=5, p=11, k=2, b=(1-1)/2=0 and a(5) = 2*11 = 22. If n=20, p=71, k=17, b=(7-1)/2=3 and a(20) = 14*71 = 994. - Andrés Ventas, Mar 01 2021

Extensions

Edited and extended by Robert G. Wilson v, Oct 09 2002

A282043 Let p = n-th prime == 7 mod 8; a(n) = sum of quadratic nonresidues mod p.

Original entry on oeis.org

14, 161, 279, 658, 1491, 1738, 2884, 4318, 6191, 7849, 10314, 10746, 13157, 16013, 18936, 19783, 27057, 35541, 35232, 39832, 50858, 51363, 55097, 63228, 60875, 68408, 97038, 95906, 103484, 111931, 140205, 136676, 145628, 146445, 172830, 189614, 195038, 209332, 221373, 219641, 238849, 254597
Offset: 1

Views

Author

N. J. A. Sloane, Feb 20 2017

Keywords

Crossrefs

Programs

  • Maple
    with(numtheory):
    Ql:=[]; Qu:=[]; Q:=[]; Nl:=[]; Nu:=[]; N:=[];
    for i1 from 1 to 300 do
    p:=ithprime(i1);
    if (p mod 8) = 7 then
    ql:=0; qu:=0; q:=0; nl:=0; nu:=0; n:=0;
    for j from 1 to p-1 do
    if legendre(j,p)=1 then
    q:=q+j;
    if j
  • Mathematica
    sqnr[p_] := Select[Range[p-1], JacobiSymbol[#, p] != 1&] // Total;
    sqnr /@ Select[Prime[Range[200]], Mod[#, 8] == 7&] (* Jean-François Alcover, Aug 30 2018 *)

A282721 Let p = n-th prime == 3 mod 8; a(n) = sum of quadratic residues mod p that are < p/2.

Original entry on oeis.org

1, 13, 32, 137, 306, 314, 555, 876, 1400, 1416, 1742, 2450, 3099, 3788, 4816, 5430, 6351, 7344, 8393, 9546, 12858, 13373, 15265, 17277, 16311, 18403, 19521, 22344, 21805, 23590, 25495, 26805, 30767, 30863, 31570, 35980, 40678, 43946, 45640, 49124, 50055, 52776, 58418, 66210, 71521, 71665, 83666, 81628
Offset: 1

Views

Author

N. J. A. Sloane, Feb 20 2017

Keywords

Crossrefs

Programs

  • Maple
    with(numtheory):
    Ql:=[]; Qu:=[]; Q:=[]; Nl:=[]; Nu:=[]; N:=[]; Th:=[];
    for i1 from 1 to 300 do
    p:=ithprime(i1);
    if (p mod 8) = 3 then
    ql:=0; qu:=0; q:=0; nl:=0; nu:=0; n:=0;
    for j from 1 to p-1 do
    if legendre(j,p)=1 then
      q:=q+j;
      if j
  • Mathematica
    s[p_] := Total[Select[Range[Floor[p/2]], JacobiSymbol[#, p] == 1&]];
    s /@ Select[Range[3, 2000, 8], PrimeQ] (* Jean-François Alcover, Nov 17 2017 *)
  • Python
    from sympy import isprime
    def a(p):
        r=(p - 1)//2
        t=0
        for j in range(1, r + 1):
            q=(j**2)%p
            if q<=r:t+=q
        return t
    print([a(p) for p in range(3, 2001, 8) if isprime(p)]) # Indranil Ghosh, Mar 27 2017, translated from Maple code

A282727 Let p = n-th prime == 3 mod 8; a(n) = (sum of quadratic residues mod p that are < p/2) + (sum of all quadratic residues mod p).

Original entry on oeis.org

2, 35, 108, 567, 1073, 1386, 2132, 3551, 5330, 6003, 8262, 9968, 13860, 16046, 19625, 24957, 29376, 34155, 37541, 44793, 54758, 61217, 68036, 75215, 77688, 85347, 93366, 98912, 101745, 107531, 119583, 129042, 135548, 145607, 149040, 170478, 193356, 205335, 213521, 230373, 243432, 256851, 280016, 294395
Offset: 1

Views

Author

N. J. A. Sloane, Feb 20 2017

Keywords

Comments

This is also the (sum of quadratic nonresidues mod p that are < p/2) + (sum of all quadratic nonresidues mod p) (= A282721 + A282723 = A282724 + A282726).

Crossrefs

Programs

  • Maple
    with(numtheory):
    Ql:=[]; Qu:=[]; Q:=[]; Nl:=[]; Nu:=[]; N:=[]; Th:=[];
    for i1 from 1 to 300 do
    p:=ithprime(i1);
    if (p mod 8) = 3 then
    ql:=0; qu:=0; q:=0; nl:=0; nu:=0; n:=0;
    for j from 1 to p-1 do
    if legendre(j,p)=1 then
    q:=q+j;
    if j
  • Mathematica
    v[x_, r_] := If[x <= r, 2*x, x];
    f[p_] := Module[{r}, r = (p-1)/2; Sum[v[PowerMod[j, 2, p], r], {j, 1, r}]];
    f /@ Select[Range[3, 1000, 8], PrimeQ] (* Jean-François Alcover, Nov 27 2017, after Robert Israel *)
  • Python
    from sympy import isprime
    def v(x, r):
        return 2*x if x<=r else x
    def a(p):
        r=(p - 1)//2
        return sum(v((j**2)%p, r) for j in range(1, r + 1))
    print([a(p) for p in range(3, 2001, 8) if isprime(p)]) # Indranil Ghosh, Mar 27 2017 translated from  Robert Israel's Maple program

A125615 Sum of the quadratic nonresidues of prime(n).

Original entry on oeis.org

0, 2, 5, 14, 33, 39, 68, 95, 161, 203, 279, 333, 410, 473, 658, 689, 944, 915, 1139, 1491, 1314, 1738, 1826, 1958, 2328, 2525, 2884, 2996, 2943, 3164, 4318, 4585, 4658, 5004, 5513, 6191, 6123, 6683, 7849, 7439, 8413, 8145, 10314, 9264, 9653, 10746, 11394
Offset: 1

Views

Author

Nick Hobson, Nov 30 2006

Keywords

Comments

For all n > 2, prime(n) divides a(n).

Examples

			The quadratic nonresidues of 7=prime(4) are 3, 5 and 6. Hence a(4) = 3+5+6 = 14.
		

References

  • D. M. Burton, Elementary Number Theory, McGraw-Hill, Sixth Edition (2007), p. 185.

Crossrefs

Sums of residues, nonresidues, and their differences, for p == 1 (mod 4), p == 3 (mod 4), and all p: A171555; A282035, A282036, A282037; A076409, A125615, A282038.

Programs

  • Mathematica
    Table[p=Prime[n];Total[Complement[Range[p-1],Union[Table[PowerMod[k, 2, p], {k, p}]]]],{n,47}] (* James C. McMahon, Dec 19 2024 *)
  • PARI
    vector(47, n, p=prime(n); t=1; for(i=2, (p-1)/2, t+=((i^2)%p)); p*(p-1)/2-t)

Formula

If prime(n) = 4k+1 then a(n) = k(4k+1) = A076409(n).

A171555 Numbers of the form prime(n)*(prime(n)-1)/4.

Original entry on oeis.org

5, 39, 68, 203, 333, 410, 689, 915, 1314, 1958, 2328, 2525, 2943, 3164, 4658, 5513, 6123, 7439, 8145, 9264, 9653, 13053, 13514, 14460, 16448, 18023, 19113, 19670, 21389, 24414, 25043, 28308, 30363, 31064, 34689, 37733, 39303, 40100, 41718, 44205, 46764, 50288
Offset: 1

Views

Author

Juri-Stepan Gerasimov, Dec 11 2009

Keywords

Comments

The halves of even numbers of the form p(p-1)/2 for p prime.
Sum of the quadratic residues of primes of the form 4k + 1. For example, a(3)=68 because 17 is the 3rd prime of the form 4k + 1 and the quadratic residues of 17 are 1, 4, 9, 16, 8, 2, 15, 13 which sum to 68. This sum is also the sum of the quadratic nonresidues. Cf. A230077. - Geoffrey Critzer, May 07 2015

References

  • R. Crandall and C. Pomerance, Prime Numbers: A Computational Perspective, Springer, NY, 2001; see Exercise 2.21 p. 110.

Crossrefs

Sums of residues, nonresidues, and their differences, for p == 1 (mod 4), p == 3 (mod 4), and all p: A171555; A282035, A282036, A282037; A076409, A125615, A282038.

Programs

  • Mathematica
    Table[Table[Mod[a^2, p], {a, 1, (p - 1)/2}] // Total, {p,
    Select[Prime[Range[100]], Mod[#, 4] == 1 &]}] (* Geoffrey Critzer, May 07 2015 *)
    Select[(# (#-1))/4&/@Prime[Range[100]],IntegerQ] (* Harvey P. Dale, Dec 24 2022 *)
  • PARI
    lista(nn) = forprime(p=2, nn, if ((p % 4)==1, print1(p*(p-1)/4, ", "))); \\ Michel Marcus, Mar 23 2016

Extensions

Corrected (16448 inserted, 25043 inserted) by R. J. Mathar, May 22 2010

A282036 a(n) is the sum of quadratic nonresidues of A002145(n) (the n-th prime == 3 mod 4).

Original entry on oeis.org

2, 14, 33, 95, 161, 279, 473, 658, 944, 1139, 1491, 1738, 1826, 2884, 2996, 4318, 4585, 5004, 6191, 6683, 7849, 8413, 10314, 10746, 11394, 13157, 13393, 16013, 16566, 18936, 19783, 20376, 23946, 27057, 27804, 30883, 35541, 35232, 36384, 39832, 45671, 50858, 51363, 50059, 55097, 56040
Offset: 1

Views

Author

N. J. A. Sloane, Feb 20 2017

Keywords

Crossrefs

Sums of residues, nonresidues, and their differences, for p == 1 mod 4, p == 3 mod 4, and all p: A171555; A282035, A282036, A282037; A076409, A125615, A282038.
Cf. A002145.

Programs

  • 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:
    a; m; d; # A282035, A282036, A282037
    # 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 *)
  • 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

Formula

a(n) = Sum_{k=1..(A002145(n)-1)/2} (-k^2) mod A002145(n). - J. M. Bergot and Robert Israel, Nov 09 2020

A282037 Let p = n-th prime == 3 mod 4; a(n) = (sum of quadratic nonresidues mod p) - (sum of quadratic residues mod p).

Original entry on oeis.org

1, 7, 11, 19, 69, 93, 43, 235, 177, 67, 497, 395, 249, 515, 321, 635, 655, 417, 1057, 163, 1837, 895, 2483, 1791, 633, 1561, 1135, 3585, 1757, 3419, 2981, 849, 921, 5909, 993, 1735, 6821, 3303, 1137, 6511, 3771, 9051, 6585, 2215, 3241, 3269, 11975, 3409, 4419, 1497, 10563, 2615, 1641, 5067, 2855
Offset: 1

Views

Author

N. J. A. Sloane, Feb 20 2017

Keywords

Comments

Equals A282036 - A282035.

Crossrefs

Sums of residues, nonresidues, and their differences, for p == 1 mod 4, p == 3 mod 4, and all p: A171555; A282035, A282036, A282037; A076409, A125615, A282038.

Programs

  • 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:
    a; m; d; # A282035, A282036, A282037
  • Mathematica
    sum[p_] := Total[If[JacobiSymbol[#, p] == 1, -#, #]& /@ Range[p-1]];
    sum /@ Select[Prime[Range[200]], Mod[#, 4] == 3&] (* Jean-François Alcover, Aug 31 2018 *)

A282038 (Sum of the quadratic nonresidues of prime(n)) - (sum of the quadratic residues of prime(n)).

Original entry on oeis.org

-1, 1, 0, 7, 11, 0, 0, 19, 69, 0, 93, 0, 0, 43, 235, 0, 177, 0, 67, 497, 0, 395, 249, 0, 0, 0, 515, 321, 0, 0, 635, 655, 0, 417, 0, 1057, 0, 163, 1837, 0, 895, 0, 2483, 0, 0, 1791, 633, 1561, 1135, 0, 0, 3585, 0, 1757, 0, 3419, 0, 2981, 0, 0, 849, 0, 921, 5909, 0, 0, 993, 0, 1735, 0, 0, 6821, 3303, 0
Offset: 1

Views

Author

N. J. A. Sloane, Feb 20 2017

Keywords

Comments

Equals 0 if p == 1 (mod 4).

Crossrefs

Sums of residues, nonresidues, and their differences, for p == 1 (mod 4), p == 3 (mod 4), and all p: A171555; A282035, A282036, A282037; A076409, A125615, A282038.

Programs

  • Maple
    with(numtheory):
    a:=[]; m:=[]; d:=[];
    for i1 from 1 to 100 do
    p:=ithprime(i1);
    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];
    od:
    a; m; d; # A076409, A125615, A282038
  • Mathematica
    sum[p_] := Total[If[JacobiSymbol[#, p] == 1, -#, #]& /@ Range[p-1]];
    a[n_] := sum[Prime[n]];
    Array[a, 100] (* Jean-François Alcover, Aug 31 2018 *)
  • PARI
    a(n) = my (p=prime(n)); return (sum(i=1, p-1, if (kronecker(i,p)==1, -i, +i))) \\ Rémy Sigrist, Apr 28 2017

A282039 Let p = n-th prime == 7 mod 8; a(n) = sum of quadratic residues mod p that are < p/2.

Original entry on oeis.org

3, 33, 60, 138, 315, 390, 663, 1008, 1425, 1743, 2280, 2475, 3108, 3570, 4323, 4590, 6045, 8055, 8418, 9168, 11610, 12045, 13398, 14340, 14823, 15813, 22425, 23028, 24885, 26163, 32310, 33033, 34503, 35250, 42333, 43995, 46548, 49173, 51870, 52785, 58443, 60393, 61380, 66435, 67470, 70623
Offset: 1

Views

Author

N. J. A. Sloane, Feb 20 2017

Keywords

Crossrefs

Programs

  • Maple
    with(numtheory):
    Ql:=[]; Qu:=[]; Q:=[]; Nl:=[]; Nu:=[]; N:=[];
    for i1 from 1 to 300 do
    p:=ithprime(i1);
    if (p mod 8) = 7 then
    ql:=0; qu:=0; q:=0; nl:=0; nu:=0; n:=0;
    for j from 1 to p-1 do
    if legendre(j,p)=1 then
      q:=q+j;
      if j
  • Mathematica
    sum[p_]:= Total[If[#
Showing 1-10 of 18 results. Next