login
a(n) = n^n (mod 4).
3

%I #37 Sep 08 2022 08:46:01

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

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

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

%N a(n) = n^n (mod 4).

%C Apart from a(0), the same as A109718. [_Joerg Arndt_, Sep 17 2013]

%C Periodic for n>0 with period 4 = A174824(4): repeat [1, 0, 3, 0].

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

%F From _Bruno Berselli_, Jan 18 2012: (Start)

%F G.f.: (1+x+3x^3-x^4)/(1-x^4).

%F a(n) = (1-(-1)^n)*(2+i^(n+1))/2 with i=sqrt(-1), a(0)=1.

%F a(n) = A109718(n) for n>0. (End)

%F a(2k) = A000007(k), a(2k+1) = A010684(k). - _Wesley Ivan Hurt_, Jun 15 2016

%p A204689:=n->n^n mod 4: seq(A204689(n), n=0..150); # _Wesley Ivan Hurt_, Jun 15 2016

%t Table[PowerMod[n, n, 4], {n,0,140}]

%o (Magma) [1] cat &cat [[1, 0, 3, 0]^^30]; // _Wesley Ivan Hurt_, Jun 15 2016

%Y Cf. A000007, A010684, A109718, A174824.

%K nonn,easy

%O 0,4

%A _José María Grau Ribas_, Jan 18 2012