login
This site is supported by donations to The OEIS Foundation.

 

Logo

Invitation: celebrating 50 years of OEIS, 250000 sequences, and Sloane's 75th, there will be a conference at DIMACS, Rutgers, Oct 9-10 2014.

Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A000224 Number of squares mod n. 34
1, 2, 2, 2, 3, 4, 4, 3, 4, 6, 6, 4, 7, 8, 6, 4, 9, 8, 10, 6, 8, 12, 12, 6, 11, 14, 11, 8, 15, 12, 16, 7, 12, 18, 12, 8, 19, 20, 14, 9, 21, 16, 22, 12, 12, 24, 24, 8, 22, 22, 18, 14, 27, 22, 18, 12, 20, 30, 30, 12, 31, 32, 16, 12, 21, 24, 34, 18, 24, 24, 36, 12 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,2

REFERENCES

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, Math. Mag. 69 (1996) 285-289.

LINKS

T. D. Noe, Table of n, a(n) for n=1..10000

S. R. Finch and Pascal Sebah, Squares and Cubes Modulo n (arXiv:math.NT/0604465).

FORMULA

a(n) = A105612(n) + 1.

Multiplicative with a(p^e) = [p^e/6]+2 if p = 2; [p^(e+1)/(2p+2)]+1 if p > 2. - David W. Wilson, Aug 01 2001

MAPLE

seq(nops({seq(n^2 mod k, n=1..100)}), k=1..65); (E. Deutsch)

MATHEMATICA

Length[Union[#]]& /@ Table[Mod[k^2, n], {n, 65}, {k, n}] (* Jean-François Alcover, Aug 30 2011 *)

PROG

(PARI) a(n) = local(v, i); v = vector(n, i, 0); for(i=0, floor(n/2), v[i^2%n+1] = 1); sum(i=1, n, v[i]) - Franklin T. Adams-Watters, Nov 05 2006

(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)) \\ Charles R Greathouse IV, Jul 15 2011

(Haskell)

a000224 n = product $ zipWith f (a027748_row n) (a124010_row n) where

   f 2 e = 2 ^ e `div` 6 + 2

   f p e = p ^ (e + 1) `div` (2 * p + 2) + 1

-- Reinhard Zumkeller, Aug 01 2012

CROSSREFS

Cf. A095972, A046530 (cubic residues), A052273 (4th powers), A052274 (5th powers), A052275 (6th powers), A085310 (7th powers), A085311 (8th powers), A085312 (9th powers), A085313 (10th powers), A085314 (11th powers), A228849 (12th powers).

Sequence in context: A144000 A085202 A096009 * A085201 A051601 A193921

Adjacent sequences:  A000221 A000222 A000223 * A000225 A000226 A000227

KEYWORD

nonn,easy,nice,mult

AUTHOR

N. J. A. Sloane.

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Superseeker | Recent | More pages
The OEIS Community | Maintained by The OEIS Foundation Inc.

Content is available under The OEIS End-User License Agreement .

Last modified July 26 09:11 EDT 2014. Contains 244925 sequences.