A338209 a(1) = 1, a(n) is the least m not already in the sequence whose binary expansion ends with the binary expansion of the binary weight of a(n-1).
1, 3, 2, 5, 6, 10, 14, 7, 11, 15, 4, 9, 18, 22, 19, 23, 12, 26, 27, 20, 30, 28, 31, 13, 35, 39, 36, 34, 38, 43, 44, 47, 21, 51, 52, 55, 29, 60, 68, 42, 59, 37, 63, 46, 76, 67, 71, 84, 75, 92, 100, 79, 45, 108, 116, 124, 53, 132, 50, 83, 140, 87, 61, 69, 91, 77
Offset: 1
Examples
a(2) = 3 since the binary weight of 1 is 1, and 3 = 1 (mod 2^1). a(3) = 2 since wt(3) = 2, and 2 = 2 (mod 2^2). a(4) = 5 since wt(2) = 1, 5 = 1 (mod 2^1), etc.
Links
- Michael De Vlieger, Table of n, a(n) for n = 1..16385
- Michael De Vlieger, Annotated plot (n, a(n)) for 1 <= n <= 2^8, color coded to show k (mod 8).
- Michael De Vlieger, Enlarged plot (n, a(n)) for 1 <= n <= 2^14, color coded to show k (mod 8).
- Michael De Vlieger, Log-log plot (n, a(n)) for 1 <= n <= 2^14, color coded to show k (mod 8), showing branching points.
- Michael De Vlieger, Persistence plot (n, a(n)) for 1 <= n <= 2^8, color coded to show consecutive repetitions of the same binary weight.
- 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 = DigitCount[#[[-1]], 2, 1], s}, s = IntegerLength[r, 2]; While[Nand[FreeQ[#, k], Mod[k, 2^s] == 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") pow2 = 2**(len(bin(binwt))-2) while binwt in used: binwt += pow2 alst.append(binwt); used.add(binwt) return alst # use alst[n-1] for a(n) print(aupto(66)) # Michael S. Branicky, Dec 16 2020
Comments