%I #22 Feb 27 2020 23:23:10
%S 1,2,1,3,1,2,1,4,1,3,1,3,1,2,1,5,1,12,1,4,1,2,1,4,1,3,1,3,1,2,1,6,1,
%T 15,1,23,1,2,1,5,1,4,1,4,1,2,1,5,1,4,1,4,1,2,1,4,1,3,1,3,1,2,1,7,1,19,
%U 1,30,1,2,1,47,1,57,1,5,1,2,1,6,1,20,1,5
%N Start with an empty stack S; for n = 1, 2, 3, ..., interpret the binary representation of n from left to right as follows: in case of bit 1, push the number 1 on top of S, in case of bit 0, replace the two numbers on top of S with their sum; a(n) gives the number on top of S after processing n.
%C After processing n, S has A268289(n) elements, the sum of which is A000788(n).
%C Every positive integer appears infinitely many times in the sequence.
%C The sequence has the same shape when represented at different scales.
%H Rémy Sigrist, <a href="/A308551/b308551.txt">Table of n, a(n) for n = 1..8192</a>
%H Sean A. Irvine, <a href="https://github.com/archmageirvine/joeis/blob/master/src/irvine/oeis/a308/A308551.java">Java program</a> (github)
%H Rémy Sigrist, <a href="/A308551/a308551.gp.txt">PARI program</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Stack_(abstract_data_type)">Stack (abstract data type)</a>
%F a(n) = 1 iff n is odd.
%F a(A020989(k)) = k + 1 for any k >= 0.
%F If n is in A014486, then a(n) = a(n-1) + A000120(n) = 1 + A000120(n). - _Charlie Neder_, Jun 07 2019
%e The first terms, alongside the binary representation of n and the evolution of stack S, are:
%e n a(n) bin(n) S
%e - ---- ------ -------------------------------------------------
%e 1 1 1 () -> (1)
%e 2 2 10 (1) -> (1,1) -> (2)
%e 3 1 11 (2) -> (2,1) -> (2,1,1)
%e 4 3 100 (2,1,1) -> (2,1,1,1) -> (2,1,2) -> (2,3)
%e 5 1 101 (2,3) -> (2,3,1) -> (2,4) -> (2,4,1)
%e 6 2 110 (2,4,1) -> (2,4,1,1) -> (2,4,1,1,1) -> (2,4,1,2)
%o (Java) See Links section.
%o (PARI) See Links section.
%Y Cf. A000788, A020989, A268289.
%K nonn,base,look
%O 1,2
%A _Rémy Sigrist_, Jun 07 2019
|