A339024 a(1) = 1, a(n) is the least m not already in the sequence whose binary expansion begins with the binary expansion of the binary weight of a(n-1).
1, 2, 3, 4, 5, 8, 6, 9, 10, 11, 7, 12, 16, 13, 14, 15, 17, 18, 19, 24, 20, 21, 25, 26, 27, 32, 22, 28, 29, 33, 23, 34, 35, 30, 36, 37, 31, 40, 38, 48, 39, 64, 41, 49, 50, 51, 65, 42, 52, 53, 66, 43, 67, 54, 68, 44, 55, 45, 69, 56, 57, 70, 58, 71, 72, 46, 73, 59
Offset: 1
Examples
Let wt(n) = A000120(n). a(2) = 2 since wt(a(1)) = wt(1) = 1, and we find "1" at the beginning of the binary expansion of the yet unused 2 = "10"_2. a(3) = 3 since wt(2) = 1, we find "1" as first bit of yet unused 3 = "11"_2. a(4) = 4 since wt(3) = 2 = "10"_2, we find "10" as first bits of yet unused 4 = "100"_2. a(5) = 5 since wt(4) = 1, and yet unused 5 = "101"_2 starts with 1. a(6) = 8 since wt(5) = 2 = "10"_2; we see that the yet unused 6 and 7 start with "11"_2, and it isn't until 8 that we have a number that when expressed in binary starts with "10"_2. a(7) = 6 since wt(8) = 1, we can now apply the yet unused 6 = "110"_2 because it starts with 1, etc.
Links
- Michael De Vlieger, Table of n, a(n) for n = 1..16384
- Michael De Vlieger, Plot (n, a(n)) for 1 <= n <= 2^10 color-coded to show wt(a(n-1)), with the first term in the family indicated.
- Michael De Vlieger, Plot (n, a(n)/A007814(a(n))) for 1 <= n <= 2^11, color-coded to show wt(a(n-1)).
- Wikipedia, Hamming weight.
- Wolfram Research, Numbers in Pascal's triangle.
- Index entries for sequences related to binary expansion of n.
Programs
-
Mathematica
Nest[Append[#, Block[{k = 1, r = IntegerDigits[DigitCount[#[[-1]], 2, 1], 2]}, While[Nand[FreeQ[#, k], Take[IntegerDigits[k, 2], Length@ r] == r], k++]; k]] & @@ {#, Length@ #} &, {1}, 2^7]
-
Python
def aupto(n): alst, used = [1], {1} for i in range(2, n+1): binprev = bin(alst[-1])[2:] binwt = binprev.count("1") lsbs, extra = 0, 0 while binwt + extra in used: lsbs += 1 binwt *= 2 for extra in range(2**lsbs): if binwt + extra not in used: break alst.append(binwt+extra); used.add(binwt+extra) return alst # use alst[n-1] for a(n) print(aupto(68)) # Michael S. Branicky, Dec 16 2020
Comments