OFFSET
1,4
COMMENTS
A218578(n) is the number of times n occurs in this sequence. - Dmitri Kamenetsky, Nov 03 2012
LINKS
T. D. Noe, Table of n, a(n) for n = 1..10000
Eric Weisstein's World of Mathematics, Quadratic Nonresidue
FORMULA
a(n) = n - A000224(n). - R. J. Mathar, Nov 05 2012
MAPLE
A095972 := proc(n)
local a, q;
a := 0 ;
for q from 0 to n-1 do
if numtheory[quadres](q, n) = -1 then
a := a+1 ;
end if;
end do;
a ;
end proc: # R. J. Mathar, Nov 05 2012
MATHEMATICA
Table[Length[Complement[Range[n-1], Union[Mod[Range[n]^2, n]]]], {n, 100}] (* T. D. Noe, Nov 06 2012 *)
PROG
(PARI) A095972(n)={local(v); v=vector(n, i, 1); for(i=0, floor(n/2), v[i^2%n+1]=0); sum(i=1, n, v[i])} \\ Michael B. Porter, Apr 30 2010
(PARI) a(n)=my(f=factor(n)); n-prod(i=1, #f[, 1], if(f[i, 1]==2, 2^f[1, 2]\6+2, f[i, 1]^(f[i, 2]+1)\(2*f[i, 1]+2)+1)) \\ Charles R Greathouse IV, Jul 15 2011
(Python)
from math import prod
from sympy import factorint
def A095972(n): return n-prod((p**(e+1)//((p+1)*(q:=1+(p==2)))>>1)+q for p, e in factorint(n).items()) # Chai Wah Wu, Oct 07 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Cino Hilliard, Jul 21 2004
EXTENSIONS
Edited by Don Reble, May 07 2006
STATUS
approved