login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 56th year, we are closing in on 350,000 sequences, and we’ve crossed 9,700 citations (which often say “discovered thanks to the OEIS”).

Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A288677 Every element of Z/nZ can be expressed as a sum of no more than a(n) squares. 1
1, 2, 3, 2, 2, 2, 4, 3, 2, 2, 3, 2, 2, 2, 4, 2, 3, 2, 3, 2, 2, 2, 4, 2, 2, 3, 3, 2, 2, 2, 4, 2, 2, 2, 3, 2, 2, 2, 4, 2, 2, 2, 3, 3, 2, 2, 4, 3, 2, 2, 3, 2, 3, 2, 4, 2, 2, 2, 3, 2, 2, 3, 4, 2, 2, 2, 3, 2, 2, 2, 4, 2, 2, 2, 3, 2, 2, 2, 4, 3, 2, 2, 3, 2, 2, 2, 4, 2, 3, 2, 3, 2, 2, 2, 4, 2, 3, 3, 3 (list; graph; refs; listen; history; text; internal format)
OFFSET

2,2

LINKS

Matthew Conroy, Table of n, a(n) for n = 2..10000

Charles Small, Waring's problem mod n, Amer. Math. Monthly 84 (1977), no. 1, 12--25.

FORMULA

From Small's paper, theorem 3.1: a(n)=1 if n=2; else a(n)=2 if n != 0 mod 4 and p^2|n implies p=1 mod 4; else a(n)=3 if n!=0 mod 8; else a(n)=4.

EXAMPLE

0^2 = 0 and 1^2 = 1 mod 2, so each element of Z/2Z is a square, so a(2)=1;

0^2 = 0, 1^2 = 2^2 = 1 mod 3, so 2 = 1^2 + 1^2 requires two squares to sum to 2, so a(3)=2.

MATHEMATICA

a[n_] := Which[n == 2, 1, Mod[n, 4] != 0 && AllTrue[Select[Divisors[n] // Sqrt, IntegerQ], Mod[#, 4] == 1&], 2, Mod[n, 8] != 0, 3, True, 4];

Table[a[n], {n, 2, 140}] (* Jean-François Alcover, Jun 13 2017 *)

PROG

(PARI) c(n) = A=factor(n); ok=1; for(i=1, matsize(A)[1], if(A[i, 1]%4==3&&A[i, 2]>1, ok=0)); return(ok); wn(n) = if(n==2, 1, if(n%4>0&&c(n)==1, 2, if(n%8>0, 3, 4))); for(ii=2, 140, print1(wn(ii), ", "))

CROSSREFS

Cf. A287286.

Sequence in context: A305048 A205717 A304689 * A187757 A286529 A306225

Adjacent sequences:  A288674 A288675 A288676 * A288678 A288679 A288680

KEYWORD

nonn

AUTHOR

Matthew Conroy, Jun 13 2017

STATUS

approved

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified December 6 19:17 EST 2021. Contains 349567 sequences. (Running on oeis4.)