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.

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

This page as a plain text file.
%I A178151 #4 Feb 10 2017 09:43:21
%S A178151 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,
%T A178151 31,27,28,34,40,34,39,37,41,39,42,47,43,52,45,54,48,49,54,57,59,64,57,
%U A178151 58,67,60,73,64,72,67,73,69,70,75,73,81,87,78,79,87,84,94,87,88,99,96,93
%N A178151 The number of quadratic residues (mod p) less than p/2, where p=prime(n).
%C A178151 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.
%H A178151 R. J. Mathar, <a href="/A178151/b178151.txt">Table of n, a(n) for n = 2..3132</a>
%H A178151 MathOverflow, <a href="http://mathoverflow.net/questions/25263">Most squares in the first half-interval</a>
%e A178151 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.
%p A178151 A178151 := proc(n)
%p A178151     local r,a,p;
%p A178151     p := ithprime(n) ;
%p A178151     a := 0 ;
%p A178151     for r from 1 to p/2 do
%p A178151         if numtheory[legendre](r,p) =1 then
%p A178151             a := a+1 ;
%p A178151         end if;
%p A178151     end do:
%p A178151     a;
%p A178151 end proc: # _R. J. Mathar_, Feb 10 2017
%t A178151 Table[p=Prime[n]; Length[Select[Range[(p-1)/2], JacobiSymbol[ #,p]==1&]], {n,2,100}]
%Y A178151 Cf. A178152, A178153, A178154
%K A178151 nonn
%O A178151 2,3
%A A178151 _T. D. Noe_, May 21 2010