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-5 of 5 results.

A178153 Difference between the numbers of quadratic residues (mod p) less than p/2 and greater than p/2, where p=prime(n).

Original entry on oeis.org

1, 0, 1, 3, 0, 0, 3, 3, 0, 3, 0, 0, 3, 5, 0, 9, 0, 3, 7, 0, 5, 9, 0, 0, 0, 5, 9, 0, 0, 5, 15, 0, 9, 0, 7, 0, 3, 11, 0, 15, 0, 13, 0, 0, 9, 9, 7, 15, 0, 0, 15, 0, 21, 0, 13, 0, 11, 0, 0, 9, 0, 9, 19, 0, 0, 9, 0, 15, 0, 0, 19, 9, 0, 9, 17, 0, 0, 0, 0, 27, 0, 21, 0, 15, 15, 0, 0, 0, 7, 21, 25, 7, 27, 9, 21, 0
Offset: 2

Views

Author

T. D. Noe, May 21 2010

Keywords

Comments

When prime(n)=1 (mod 4), then a(n)=0. When prime(n)=3 (mod 4), then a(n)>0. When prime(n)=3 (mod 8) and prime(n)>3, then 3 divides a(n). See Borevich and Shafarevich. The nonzero terms of this sequence are closely related to A002143, the class number of primes p=3 (mod 4).
Same as difference between the numbers of quadratic residues and nonresidues (mod p) less than p/2, where p=prime(n). - Jonathan Sondow, Oct 30 2011

Examples

			The quadratic residues of 19, the 8th prime, are 1, 4, 5, 6, 7, 9, 11, 16, 17. Hence a(8)=6-3=3.
		

References

  • Z. I. Borevich and I. R. Shafarevich, Number Theory, Academic Press, NY, 1966, p. 346.
  • H. Davenport, Multiplicative Number Theory, Graduate Texts in Math. 74, 2nd ed., Springer, 1980, p. 51.

Crossrefs

Cf. A002143, A178154 (without the zero terms).

Programs

  • Maple
    A178153 := proc(n)
        local r,a,p;
        p := ithprime(n) ;
        a := 0 ;
        for r from 1 to p/2 do
            if numtheory[legendre](r,p) =1 then
                a := a+1 ;
            end if;
        end do:
        for r from ceil(p/2) to p-1 do
            if numtheory[legendre](r,p) =1 then
                a := a-1 ;
            end if;
        end do:
        a;
    end proc: # R. J. Mathar, Feb 10 2017
  • Mathematica
    Table[p=Prime[n]; Length[Select[Range[(p-1)/2], JacobiSymbol[ #,p]==1&]] - Length[Select[Range[(p+1)/2,p-1], JacobiSymbol[ #,p]==1&]], {n,2,100}]
    Table[p = Prime[n]; Sum[ JacobiSymbol[a, p], {a, 1, (p-1)/2}], {n, 2, 100}] (* Jonathan Sondow, Oct 30 2011 *)

Formula

a(n) = A178151(n) - A178152(n).
a(n) = Sum_{j=1..(p-1)/2} (j|p), where p = prime(n) and (j|p) = +-1 is the Legendre symbol. - Jonathan Sondow, Oct 30 2011

A178151 The number of quadratic residues (mod p) less than p/2, where p=prime(n).

Original entry on oeis.org

1, 1, 2, 4, 3, 4, 6, 7, 7, 9, 9, 10, 12, 14, 13, 19, 15, 18, 21, 18, 22, 25, 22, 24, 25, 28, 31, 27, 28, 34, 40, 34, 39, 37, 41, 39, 42, 47, 43, 52, 45, 54, 48, 49, 54, 57, 59, 64, 57, 58, 67, 60, 73, 64, 72, 67, 73, 69, 70, 75, 73, 81, 87, 78, 79, 87, 84, 94, 87, 88, 99, 96, 93
Offset: 2

Views

Author

T. D. Noe, May 21 2010

Keywords

Comments

Sequence A063987 lists the quadratic residues (mod p) for each prime p. When p=1 (mod 4), there are an equal number of quadratic residues less than p/2 and greater than p/2. When p=3 (mod 4), there are always more quadratic residues less than p/2 than greater than p/2.

Examples

			The quadratic residues of 19, the 8th prime, are 1, 4, 5, 6, 7, 9, 11, 16, 17. Six of these are less than 19/2. Hence a(8)=6.
		

Crossrefs

Programs

  • Maple
    A178151 := proc(n)
        local r,a,p;
        p := ithprime(n) ;
        a := 0 ;
        for r from 1 to p/2 do
            if numtheory[legendre](r,p) =1 then
                a := a+1 ;
            end if;
        end do:
        a;
    end proc: # R. J. Mathar, Feb 10 2017
  • Mathematica
    Table[p=Prime[n]; Length[Select[Range[(p-1)/2], JacobiSymbol[ #,p]==1&]], {n,2,100}]

A178152 The number of quadratic residues (mod p) greater than p/2, where p=prime(n).

Original entry on oeis.org

0, 1, 1, 1, 3, 4, 3, 4, 7, 6, 9, 10, 9, 9, 13, 10, 15, 15, 14, 18, 17, 16, 22, 24, 25, 23, 22, 27, 28, 29, 25, 34, 30, 37, 34, 39, 39, 36, 43, 37, 45, 41, 48, 49, 45, 48, 52, 49, 57, 58, 52, 60, 52, 64, 59, 67, 62, 69, 70, 66, 73, 72, 68, 78, 79, 78, 84, 79, 87, 88, 80, 87, 93, 90
Offset: 2

Views

Author

T. D. Noe, May 21 2010

Keywords

Comments

Sequence A063987 lists the quadratic residues (mod p) for each prime p. When p=1 (mod 4), there are an equal number of quadratic residues less than p/2 and greater than p/2. When p=3 (mod 4), there are always more quadratic residues less than p/2 than greater than p/2.

Examples

			The quadratic residues of 19, the 8th prime, are 1, 4, 5, 6, 7, 9, 11, 16, 17. Three of these are greater than 19/2. Hence a(8)=3.
		

Crossrefs

Programs

  • Mathematica
    Table[p=Prime[n]; Length[Select[Range[(p+1)/2,p-1], JacobiSymbol[ #,p]==1&]], {n,2,100}]

A186708 Number of quadratic residues (mod p) in the interval [1,2k+1], for primes p=4k+3.

Original entry on oeis.org

1, 2, 4, 6, 7, 9, 12, 14, 19, 18, 21, 22, 25, 28, 31, 34, 40, 39, 41, 42, 47, 52, 54, 54, 57, 59, 64, 67, 73, 72, 73, 75, 81, 87, 87, 94, 99, 96, 99, 104, 118, 118, 117, 118, 119, 127, 132, 125, 136, 129, 136, 138, 141, 154, 150, 157, 162
Offset: 1

Views

Author

M. F. Hasler, Feb 25 2011

Keywords

Comments

For primes of the form p=4k+3 (A002145), count numbers in [1,2k+1] which are quadratic residues mod p.
R. K. Guy asks whether there is an elementary proof for the fact that there are always less quadratic residues in the interval [2k+2,4k+2] than in [1,2k+1].

Crossrefs

Programs

  • PARI
    forprime( p=1,499, p%4==3|next; u=3; c=[1,0]; for(i=2,p-2, bittest(u,i^2%p) & next; u+=1<<(i^2%p); c[i^2%p*2\p+1]++); print1(c[1]", "))

Formula

a(n) = A104635(n) - A186709(n) = A186709(n) + A178154(n) = (A104635(n) + A178154(n))/2 = (A002145(n) + 2*A178154(n) - 1)/4.

A186709 Number of quadratic residues (mod p) in the interval [2k+2,4k+2], for primes p=4k+3.

Original entry on oeis.org

0, 1, 1, 3, 4, 6, 9, 9, 10, 15, 14, 17, 16, 23, 22, 29, 25, 30, 34, 39, 36, 37, 41, 45, 48, 52, 49, 52, 52, 59, 62, 66, 72, 68, 78, 79, 80, 87, 90, 87
Offset: 1

Views

Author

M. F. Hasler, Feb 25 2011

Keywords

Crossrefs

Programs

  • PARI
    forprime( p=1, 399, p%4==3|next; u=3; c=[1, 0]; for(i=2, p-2, bittest(u, i^2%p) & next; u+=1<<(i^2%p); c[i^2%p*2\p+1]++); print1(c[2]", "))

Formula

a(n) = A104635(n) - A186708(n) = A186708(n) - A178154(n) = (A104635(n) - A178154(n))/2 = (A002145(n) - 2*A178154(n) -1)/4.
Showing 1-5 of 5 results.