%I #8 Jul 06 2024 14:15:07
%S 0,1,1,0,2,1,1,2,0,1,1,2,0,1,1,2,2,1,1,0,2,1,1,0,2,1,1,0,2,1,1,0,2,1,
%T 1,0,2,1,1,0,2,1,1,2,2,1,1,2,2,1,1,2,0,1,1,2,0,1,1,2,0,1,1,2,0,1,1,2,
%U 0,1,1,2,0,1,1,2,0,1,1,2,0,1,1,2,0,1,1
%N For any n > 0, let b_n(n+1) = 0, and for k = 1..n, if b_n(k+1) >= k then b_n(k) = b_n(k+1) - k otherwise b_n(k) = b_n(k+1) + k; a(n) = b_n(1).
%C This sequence is a variant of A008344; here we add or subtract by numbers from n down to 1, there by numbers from 1 up to n.
%C Apparently, the sequence only contains 0's, 1's and 2's.
%H Rémy Sigrist, <a href="/A374318/a374318.png">Colored representation of b_n(k) for n <= 1000</a> (where the color at (x, y) is function of b_x(y))
%H Rémy Sigrist, <a href="/A374318/a374318_1.png">Log-log scatterplot of the ordinal transform of the first 10000 terms</a>
%F Empirically, a(n) = 1 iff n belongs to A042963.
%e The first terms, alongside the corresponding sequences b_n, are:
%e n a(n) b_n
%e -- ---- ----------------------------------
%e 0 0 [0]
%e 1 1 [1, 0]
%e 2 1 [1, 2, 0]
%e 3 0 [0, 1, 3, 0]
%e 4 2 [2, 3, 1, 4, 0]
%e 5 1 [1, 2, 4, 1, 5, 0]
%e 6 1 [1, 0, 2, 5, 1, 6, 0]
%e 7 2 [2, 3, 5, 2, 6, 1, 7, 0]
%e 8 0 [0, 1, 3, 6, 2, 7, 1, 8, 0]
%e 9 1 [1, 2, 0, 3, 7, 2, 8, 1, 9, 0]
%e 10 1 [1, 2, 4, 7, 3, 8, 2, 9, 1, 10, 0]
%o (PARI) a(n) = { my (b = 0); forstep (k = n, 1, -1, if (b >= k, b -= k, b += k);); return (b); }
%Y Cf. A008344, A042963, A374317.
%K nonn
%O 0,5
%A _Rémy Sigrist_, Jul 04 2024