OFFSET
1,2
COMMENTS
LINKS
M. Bunder, B. Bates, and S. Arnold, The summed paperfolding sequence, Bull. Aust. Math. Soc. (2024).
Kevin Ryde, Iterations of the Dragon Curve, see index "TurnRunStart" with a(n) = TurnRunStart(n-1).
Jeffrey Shallit, Automaton for A371594.
FORMULA
The automaton accompanying this entry accepts exactly the base-2 representations of the terms of this sequence.
a(n) = 2*n-1 - ((n + A014707(n-2)) mod 2), for n >= 2. - Kevin Ryde, Mar 28 2024
EXAMPLE
The first few terms of A014707 are 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, and runs begin at positions 1, 3, 4, 6, 8, 11, 13, 14, ...
MATHEMATICA
Abs@ SplitBy[Array[# KroneckerSymbol[-1, #] &, 120], Sign][[All, 1]] (* Michael De Vlieger, Mar 28 2024 *)
PROG
(Python) # DFA transition function and simulation
d = { (0, 0):0, (0, 1):1, (1, 0):2, (1, 1):3, (2, 0):4, (2, 1):5,
(3, 0):6, (3, 1):7, (4, 0):4, (4, 1):5, (5, 0):2, (5, 1):3,
(6, 0):0, (6, 1):1, (7, 0):6, (7, 1):7 }
def ok(n):
q, w = 0, map(int, bin(n)[2:])
for c in w: q = d[q, c]
return q in {1, 3, 4, 6}
print([k for k in range(126) if ok(k)]) # Michael S. Branicky, Mar 28 2024
(Python) # using formula and function in A014707
def a(n): return 2*n-1 - (n + A014707(n-2))%2 if n>=2 else 1
print([a(n) for n in range(1, 64)]) # Michael S. Branicky, Mar 29 2024
(PARI) a(n) = if(n==1, 1, n--; 2*n + bitxor(bittest(n, 0), bittest(n, valuation(n, 2)+1))); \\ Kevin Ryde, Apr 06 2024
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Jeffrey Shallit, Mar 28 2024
STATUS
approved