OFFSET

1,8

COMMENTS

This sequence is a variant of A308551.

After processing n, S has A268289(n) elements.

Every integer appears infinitely many times in the sequence:

- the effect of the binary string b(0) = "110" is to leave 0 on top of S,

- the effect of the binary string b(1) = "1" is to leave 1 on top of S,

- the effect of the binary string b(-1) = "11100" is to leave -1 on top of S,

- let "|" denote the binary concatenation,

- for any k > 0:

- the effect of b(k+1) = b(-1)|b(k)|"0" is to leave k+1 on top of S,

- the effect of b(-k-1) = b(1)|b(-k)|"0" is to leave -k-1 on top of S,

- for any k, for any n > 0, if the binary representation of n ends with b(k), then a(n) = k, QED,

- see A330264 for the values in order of appearance.

LINKS

Rémy Sigrist, Table of n, a(n) for n = 1..8192

Rémy Sigrist, Scatterplot of the first 2^20 terms

Rémy Sigrist, PARI program for A330261

FORMULA

a(2*k-1) = 1 for any k > 0.

EXAMPLE

The first terms, alongside the binary representation of n and the evolution of stack S, are:

n a(n) bin(n) S

-- ---- ------ ------------------------------------------------------------

1 1 1 () -> (1)

2 0 10 (1) -> (1,1) -> (0)

3 1 11 (0) -> (0,1) -> (0,1,1)

4 -1 100 (0,1,1) -> (0,1,1,1) -> (0,1,0) -> (0,-1)

5 1 101 (0,-1) -> (0,-1,1) -> (0,2) -> (0,2,1)

6 0 110 (0,2,1) -> (0,2,1,1) -> (0,2,1,1,1) -> (0,2,1,0)

7 1 111 (0,2,1,0) -> (0,2,1,0,1) -> (0,2,1,0,1,1) -> (0,2,1,0,1,1,1)

PROG

(PARI) See Links section.

CROSSREFS

KEYWORD

sign,base

AUTHOR

Rémy Sigrist, Dec 07 2019

STATUS

approved