login
A274575
For m=1,2,3,... write all the 2^m binary vectors of length m in increasing order, and replace each vector with (number of 1's) - (number of 0's). Start with an initial 0 for the empty vector.
3
0, -1, 1, -2, 0, 0, 2, -3, -1, -1, 1, -1, 1, 1, 3, -4, -2, -2, 0, -2, 0, 0, 2, -2, 0, 0, 2, 0, 2, 2, 4, -5, -3, -3, -1, -3, -1, -1, 1, -3, -1, -1, 1, -1, 1, 1, 3, -3, -1, -1, 1, -1, 1, 1, 3, -1, 1, 1, 3, 1, 3, 3, 5, -6, -4, -4, -2, -4, -2, -2, 0, -4, -2, -2, 0, -2, 0, 0, 2, -4, -2, -2, 0, -2, 0, 0, 2, -2, 0, 0, 2, 0, 2, 2, 4, -4, -2, -2, 0, -2, 0, 0, 2, -2, 0, 0, 2, 0, 2, 2, 4, -2, 0, 0, 2, 0, 2, 2, 4, 0
OFFSET
0,4
COMMENTS
This is the sequence of To-And-Fro positions: Positions of all backward-forward combinations in lexicographical order when assigning -1 to a backward move and +1 to a forward move and starting at 0.
-a(n) are the slopes of the different segments, from left to right, of the successive steps in the construction of the Takagi (a.k.a. Blancmange) function. - Javier Múgica, Dec 31 2017
LINKS
FORMULA
a(2*n + 1) = a(n) - 1; a(2*n + 2) = a(n) + 1.
a(n) = A000120(n + 1) - A008687(n + 2). - Alan Michael Gómez Calderón, Sep 11 2025
a(n) = A000120(n + 1) - A023416(n + 1) - 1. - Paolo Xausa, Sep 12 2025
EXAMPLE
Terms a(3) to a(6) correspond to the binary vectors 00, 01, 10, 11, which get replaced by -2, 0, 0, 2, respectively. Terms a(7) to a(14) correspond to the binary vectors 000, 001, ..., 111 which get replaced by -3, -1, ..., 3.
a(0) = 0
a(1) = a('backward') = -1
a(2) = a('forward') = +1
a(3) = a('backward and backward') = -2
a(4) = a('backward and forward') = 0
a(5) = a('forward and backward') = 0
a(6) = a('forward and forward') = +2
a(7) = a('backward, backward and backward') = -3
a(8) = a('backward, backward and forward') = -1
Arranged as a tree read by rows:
______0______
/ \
__-1__ __1__
/ \ / \
-2 0 0 2
/ \ / \ / \ / \
-3 -1 -1 1 -1 1 1 3
. - John Tyler Rascoe, Sep 23 2023
MATHEMATICA
A274575list[m_] := Map[2*Count[#, 1] - m &, IntegerDigits[Range[0, 2^m - 1], 2, m]];
Flatten[Array[A274575list, 7, 0]] (* or *)
A274575[n_] := 2*Count[#, 1] - Length[#] - 1 & [IntegerDigits[n + 1, 2]];
Array[A274575, 127, 0] (* Paolo Xausa, Sep 12 2025 *)
PROG
(BASIC)
Dim a(2*k+2)
a(0) = 0
For n = 0 To k
a(2 * n + 1) = a(n) - 1
a(2 * n + 2) = a(n) + 1
Next n
(Python)
def A274575_list(nmax):
A = [0]
for n in range(0, nmax):
A.append(A[n//2]-(-1)**n)
return(A)
print(A274575_list(119)) # John Tyler Rascoe, Sep 23 2023
CROSSREFS
KEYWORD
sign,easy
AUTHOR
Hans G. Oberlack, Jun 28 2016
EXTENSIONS
Edited by N. J. A. Sloane, Jul 27 2016
STATUS
approved