login
a(n) = n^2 mod 6.
20

%I #51 Dec 27 2023 14:32:43

%S 0,1,4,3,4,1,0,1,4,3,4,1,0,1,4,3,4,1,0,1,4,3,4,1,0,1,4,3,4,1,0,1,4,3,

%T 4,1,0,1,4,3,4,1,0,1,4,3,4,1,0,1,4,3,4,1,0,1,4,3,4,1,0,1,4,3,4,1,0,1,

%U 4,3,4,1,0,1,4,3,4,1,0,1,4,3,4,1,0,1,4,3,4,1,0,1,4,3,4,1,0,1,4,3,4

%N a(n) = n^2 mod 6.

%C a(m*n) = a(m)*a(n) mod 6; a(3*n+k) = a(3*n-k) for k <= 3*n. - _Reinhard Zumkeller_, Apr 24 2009

%C Equivalently n^6 mod 6. - _Zerinvary Lajos_, Nov 06 2009

%C Equivalently: n^(2*m + 4) mod 6; n^(2*m + 2) mod 6. - _G. C. Greubel_, Apr 01 2016

%H <a href="/index/Rec#order_06">Index entries for linear recurrences with constant coefficients</a>, signature (0, 0, 0, 0, 0, 1).

%F G.f.: -x*(1+4*x+3*x^2+4*x^3+x^4)/((x-1)*(1+x)*(1+x+x^2)*(x^2-x+1)). - _R. J. Mathar_, Jul 23 2009

%F a(n) = a(n-6). - _Reinhard Zumkeller_, Apr 24 2009

%F From _G. C. Greubel_, Apr 01 2016: (Start)

%F a(6*m) = 0.

%F a(2*n) = 4*A011655(n).

%F a(n) = (1/6)*(13 + 3*(-1)^n - 12*cos(n*Pi/3) - 4*cos(2*n*Pi/3)).

%F G.f.: (x +4*x^2 +3*x^3 + 4*x^4 +x^5)/(1 - x^6). (End)

%p A070431:=n->n^2 mod 6: seq(A070431(n), n=0..100); # _Wesley Ivan Hurt_, Apr 01 2016

%t Table[Mod[n^2, 6], {n, 0, 200}] (* _Vladimir Joseph Stephan Orlovsky_, Apr 21 2011 *)

%t LinearRecurrence[{0, 0, 0, 0, 0, 1},{0, 1, 4, 3, 4, 1},101] (* _Ray Chandler_, Aug 26 2015 *)

%t PowerMod[Range[0,120],2,6] (* or *) PadRight[{},120,{0,1,4,3,4,1}] (* _Harvey P. Dale_, Aug 11 2019 *)

%o (Sage) [power_mod(n,2,6) for n in range(0, 101)] # _Zerinvary Lajos_, Oct 30 2009

%o (PARI) a(n)=n^2%6 \\ _Charles R Greathouse IV_, Sep 24 2015

%o (Magma) [n^2 mod 6 : n in [0..100]]; // _Wesley Ivan Hurt_, Apr 01 2016

%o (Magma) [Modexp(n, 2, 6): n in [0..100]]; // _Vincenzo Librandi_, Apr 02 2016

%Y Cf. A000290, A008959, A070435, A070438, A070442, A070452, A159852.

%K nonn,easy

%O 0,3

%A _N. J. A. Sloane_, May 12 2002