

A249144


a(0) = 0, after which a(n) gives the total number of runs of the same length as the rightmost run in the binary representation of a(n1) [i.e., A136480(a(n1))] among the binary expansions of all previous terms, including the runs in a(n1) itself.


5



0, 1, 2, 4, 1, 6, 7, 1, 8, 2, 11, 3, 4, 5, 17, 19, 7, 4, 8, 5, 25, 26, 29, 31, 1, 32, 2, 35, 12, 14, 37, 41, 45, 49, 50, 52, 22, 57, 58, 61, 63, 1, 64, 2, 67, 25, 69, 73, 76, 32, 3, 33, 80, 4, 34, 87, 14, 92, 35, 36, 38, 99, 42, 105, 108, 47, 5, 114, 116, 49, 119, 23, 24, 25, 123, 54, 126, 127, 1, 128, 2
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

0,3


COMMENTS

Inspired by A248034.


LINKS

Antti Karttunen, Table of n, a(n) for n = 0..10000


EXAMPLE

a(0) = 0 (by definition), and 0 is also '0' in binary.
For n = 1, we see that in a(0) there is one run of length 1, which is total number of runs of length 1 so far in terms a(0) .. a(n1), thus a(1) = 1.
For n = 2, we see that the rightmost run of a(1) = 1 ('1' also in binary) has occurred two times in total (once in a(0) and a(1)), thus a(2) = 2.
For n = 3, we see that the rightmost run of a(2) = 2 ('10' in binary) is one bit long, and so far there has occurred four such runs in total (namely once in a(0) and a(1), twice in a(2)), thus a(3) = 4.
For n = 4, we see that the rightmost run of a(3) = 4 ('100' in binary) is two bits long, and it is so far the first and only twobit run in the sequence, thus a(4) = 1.
For n = 5, we see that the rightmost run of a(4) = 1 ('1' in binary) is one bit long, and so far there has occurred 6 such onebit runs in terms a(0) .. a(4), thus a(5) = 6.
For n = 6, we see that the rightmost run of a(5) = 6 ('110' in binary) is one bit long, and so far there has occurred 7 such one bit runs in terms a(0) .. a(5), thus a(6) = 7.


PROG

(MIT/GNU Scheme with memoizing definecmacro from Antti Karttunen's IntSeqlibrary)
;; For binexp>runcount1list see for example A129594.
(definec (A249144 n) (if (< n 2) n (vectorref (A249144aux_runlen_counts ( n 1)) (1+ (A136480 (A249144 ( n 1)))))))
(definec (A249144aux_runlen_counts n) (cond ((zero? n) (vector 1)) (else (let* ((a_n (A249144 n)) (copyofprevec (vectorcopy (A249144aux_runlen_counts ( n 1)))) (newsize (max (vectorlength copyofprevec) (A043276 a_n))) (lencountsforn (vectorgrow copyofprevec newsize))) (let loop ((runlens (binexp>runcount1list a_n))) (cond ((null? runlens) lencountsforn) (else (vectorset! lencountsforn ( (car runlens) 1) (+ 1 (or (vectorref lencountsforn ( (car runlens) 1)) 0))) (loop (cdr runlens)))))))))


CROSSREFS

Cf. A249143, A249146, A249148, A248034.
Sequence in context: A138124 A128860 A019680 * A080032 A297121 A105357
Adjacent sequences: A249141 A249142 A249143 * A249145 A249146 A249147


KEYWORD

nonn,base


AUTHOR

Antti Karttunen, Oct 22 2014


STATUS

approved



