OFFSET
1,5
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
S. R. Finch and Pascal Sebah, Squares and Cubes Modulo n, arXiv:math/0604465 [math.NT], 2006-2016.
E. J. F. Primrose, The number of quadratic residues mod m, Math. Gaz. v. 61 (1977) n. 415, 60-61.
W. D. Stangl, Counting Squares in Z_n, Mathematics Magazine, pp. 285-289, Vol. 69 No. 4 (October 1996).
Eric Weisstein's World of Mathematics, Quadratic Residue
FORMULA
a(n) = A000224(n) - 1.
MATHEMATICA
a[n_]:=Count[Union[Mod[Range[Floor[n/2]]^2, n]], _?Positive]; Table[a[n], {n, 1, 80}] (* Jean-François Alcover, Feb 09 2011 *)
PROG
(PARI) /* based on code by Franklin T. Adams-Watters, see A000224 */
A105612(n)=local(v, i); v=vector(n, i, 0); for(i=0, floor(n/2), v[i^2%n+1]=1); sum(i=2, n, v[i]) \\ Michael B. Porter, May 04 2010
(PARI) a(n)=my(f=factor(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))-1 \\ Charles R Greathouse IV, Sep 10 2013
(Haskell)
a105612 = (subtract 1) . a000224 -- Reinhard Zumkeller, Aug 01 2012
CROSSREFS
KEYWORD
nonn
AUTHOR
Eric W. Weisstein, Apr 15 2005
STATUS
approved