OFFSET
1,1
COMMENTS
The number of squares (quadratic residues including 0) modulo a prime p (sequence A096008 with every "1" prefixed by a "0") equals 1+floor(p/2), or ceiling(p/2) = (p+1)/2 if p is odd. (In fields of characteristic 2, all elements are squares.) See A130290(n)=A130291(n)-1 for number of nonzero residues. For all n>0, A130291(n+1) = A111333(n+1) = A006254(n) = A005097(n)-1 = A102781(n+1)-1 = A102781(n+1)-1 = A130290(n+1)-1.
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 1..1000
Eric Weisstein's World of Mathematics, Quadratic Residue
Wikipedia, Quadratic Residue
FORMULA
a(n) = floor( A000040(n)/2 )+1
EXAMPLE
a(1)=2 since both elements of Z/2Z are squares.
a(3)=0 since 0=0^2, 1=1^2=(-1)^2 and 4=2^2=(-2)^2 are squares in Z/5Z.
a(1000000) = 7742932 = (p[1000000]+1)/2.
MATHEMATICA
Quotient[Prime[Range[200]], 2] + 1 (* Vincenzo Librandi, Jan 16 2013 *)
PROG
(PARI) A130291(n) = 1+prime(n)>>1
(Magma) [Floor((NthPrime(n))/2)+1: n in [1..60]]; // Vincenzo Librandi, Jan 16 2013
CROSSREFS
Essentially the same as A006254.
Cf. A005097 (Odd primes - 1)/2, A102781 (Integer part of n#/(n-2)#/2#), A102781 (Number of even numbers less than the n-th prime), A063987 (quadratic residues modulo the n-th prime), A006254 (Numbers n such that 2n-1 is prime), A111333 (Number of odd numbers <= n-th prime), A000040 (prime numbers), A130290 (number of nonzero residues modulo primes).
KEYWORD
easy,nonn
AUTHOR
M. F. Hasler, May 21 2007
STATUS
approved