

A301984


a(n) is the greatest positive number k such that the binary digits of any number in the interval 1..k appear in order but not necessarily as consecutive digits in the binary representation of n.


1



1, 2, 1, 2, 3, 3, 1, 2, 5, 6, 3, 4, 3, 3, 1, 2, 5, 6, 5, 6, 7, 7, 3, 4, 7, 7, 3, 4, 3, 3, 1, 2, 5, 6, 5, 6, 11, 11, 5, 6, 13, 14, 7, 8, 7, 7, 3, 4, 9, 10, 7, 8, 7, 7, 3, 4, 7, 7, 3, 4, 3, 3, 1, 2, 5, 6, 5, 6, 11, 11, 5, 6, 13, 14, 11, 12, 11, 11, 5, 6, 13, 14
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,2


COMMENTS

Equivalently, a(n) is the greatest positive number k such that A301983(n, k) = k.
Apparently, the kth record value is A089633(k), and the first term with this value has index A048678(A089633(k)).


LINKS

Rémy Sigrist, Table of n, a(n) for n = 1..10000
Index entries for sequences related to binary expansion of n


FORMULA

a(n) <= A301977(n).
a(2*n) >= a(n).
a(2*n + 1) >= a(n) (with strict inequality if a(n) is even).
a(n) = 1 iff n is positive and belongs to A000225.


EXAMPLE

The 13th row of A301983 is: 1, 2, 3, 5, 6, 7, 13; all numbers in the range 1..3 appear in this row, but the number 4 is missing; hence a(13) = 3.


PROG

(PARI) a(n) = my (b=binary(n), s=Set(1)); for (i=2, #b, s = setunion(s, Set(apply(v > 2*v+b[i], s)))); for (u=1, oo, if (!setsearch(s, u), return (u1)))


CROSSREFS

Cf. A048678, A089633, A301977, A301983.
Sequence in context: A100002 A328471 A227909 * A210805 A303842 A057041
Adjacent sequences: A301981 A301982 A301983 * A301985 A301986 A301987


KEYWORD

nonn,base


AUTHOR

Rémy Sigrist, Mar 30 2018


STATUS

approved



