login

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 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A374318
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).
2
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, 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, 0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1
OFFSET
0,5
COMMENTS
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.
Apparently, the sequence only contains 0's, 1's and 2's.
FORMULA
Empirically, a(n) = 1 iff n belongs to A042963.
EXAMPLE
The first terms, alongside the corresponding sequences b_n, are:
n a(n) b_n
-- ---- ----------------------------------
0 0 [0]
1 1 [1, 0]
2 1 [1, 2, 0]
3 0 [0, 1, 3, 0]
4 2 [2, 3, 1, 4, 0]
5 1 [1, 2, 4, 1, 5, 0]
6 1 [1, 0, 2, 5, 1, 6, 0]
7 2 [2, 3, 5, 2, 6, 1, 7, 0]
8 0 [0, 1, 3, 6, 2, 7, 1, 8, 0]
9 1 [1, 2, 0, 3, 7, 2, 8, 1, 9, 0]
10 1 [1, 2, 4, 7, 3, 8, 2, 9, 1, 10, 0]
PROG
(PARI) a(n) = { my (b = 0); forstep (k = n, 1, -1, if (b >= k, b -= k, b += k); ); return (b); }
CROSSREFS
KEYWORD
nonn
AUTHOR
Rémy Sigrist, Jul 04 2024
STATUS
approved