OFFSET
1,2
COMMENTS
An alternative name: The smallest number whose binary expansion has exactly n distinct run-lengths. - Gus Wiseman, Feb 21 2022
Term a(n) has one 1, followed by n 0's, then two 1's, (n-1) 0's, ..., up to n runs; see Python program. - Michael S. Branicky, Feb 22 2022
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..81
EXAMPLE
a(1) in binary is 1, a(2) in binary is 100, a(3) in binary is 100011, a(4) in binary is 1000011000, etc.
From Gus Wiseman, Feb 21 2022: (Start)
The terms and their binary expansions begin:
n a(n)
1: 1 = 1
2: 4 = 100
3: 35 = 100011
4: 536 = 1000011000
5: 16775 = 100000110000111
6: 1060976 = 100000011000001110000
7: 135007759 = 1000000011000000111000001111
8: 34460631520 = 100000000110000000111000000111100000
9: 17617985239071 = 100000000011000000001110000000111100000011111
(End)
MATHEMATICA
g[n_] := Table[ {Table[1, {i}], Table[0, {n - i + 1}]}, {i, Floor[(n + If[ OddQ@n, 1, 0])/2]}]; f[n_] := FromDigits[ If[ OddQ@n, Flatten@ Most@ Flatten[ g@n, 1], Flatten@ g@n], 2]; Array[f, 14]
s=Table[Length[Union[Length/@Split[IntegerDigits[n, 2]]]], {n, 0, 1000}]; Table[Position[s, k][[1, 1]]-1, {k, Union[s]}] (* Gus Wiseman, Feb 21 2022 *)
PROG
(Python)
def a(n): # returns term by construction
if n == 1: return 1
q, r = divmod(n+1, 2)
s = "".join("1"*i + "0"*(n+1-i) for i in range(1, q+1))
if r == 0: s = s.rstrip("0")
return int(s, 2)
print([a(n) for n in range(1, 16)]) # Michael S. Branicky, Feb 22 2022
CROSSREFS
These are the positions of first appearances in A165413.
A000120 counts binary weight.
A005811 counts runs in binary expansion.
A242882 counts compositions with distinct multiplicities.
A318928 gives runs-resistance of binary expansion.
A351014 counts distinct runs in standard compositions.
Counting words with all distinct run-lengths:
KEYWORD
easy,nonn
AUTHOR
Robert G. Wilson v, Sep 30 2009
EXTENSIONS
a(15) and beyond from Michael S. Branicky, Feb 22 2022
STATUS
approved