login
a(-1) = -1, a(0) = 1, a(n) = A317539(n) - 3*(n-1) for n > 0.
1

%I #13 Jul 23 2023 17:00:33

%S -1,1,2,0,2,1,-1,0,-1,1,-1,0,2,1,2,0,-1,1,-1,0,2,1,-1,0,-1,1,2,0,2,1,

%T 2,0,-1,1,-1,0,2,1,-1,0,-1,1,-1,0,2,1,2,0,-1,1,2,0,2,1,-1,0,-1,1,2,0,

%U 2,1,2,0,-1,1,-1,0,2,1,-1,0,-1,1,-1

%N a(-1) = -1, a(0) = 1, a(n) = A317539(n) - 3*(n-1) for n > 0.

%F a(-1) = -1, a(1) = 2, a(4n) = 1, a(4n+2) = 0, a(8n+3) = 2, a(8n+7) = -1, a(8n+1) = a(4n+1), a(1) = 2, a(8n+5) = a(4n-1), for n >= 0.

%o (Python)

%o a = [-1,1,2]

%o print(-1,-1)

%o print(0,1)

%o print(1,2)

%o n = 2

%o while n < 128:

%o if n%4 == 0:

%o a = a+[1]

%o elif n%4 == 2:

%o a = a+[0]

%o elif n%8 == 1:

%o a = a+[a[4*(n//8)+2]]

%o elif n%8 == 3:

%o a = a+[2]

%o elif n%8 == 5:

%o a = a+[a[4*(n//8)]]

%o else: # n%8 == 7

%o a = a+[-1]

%o print(n,a[n+1])

%o n = n+1

%Y Cf. A317539.

%K sign

%O -1,3

%A _A.H.M. Smeets_, Jul 30 2018

%E Offset and NAME corrected by _R. J. Mathar_, Jun 19 2021