A340069 a(n) is the smallest number k not yet used such that the number of 1-bits in the binary representation of k equals the number of 1-bits in the binary representation of k*n.
0, 1, 2, 3, 4, 7, 6, 14, 5, 15, 27, 12, 24, 10, 19, 30, 8, 31, 43, 28, 39, 13, 35, 45, 48, 62, 20, 57, 37, 63, 60, 79, 9, 126, 91, 11, 86, 29, 56, 23, 54, 75, 26, 51, 70, 46, 47, 22, 89, 21, 93, 83, 40, 61, 114, 78, 38, 18, 71, 87, 77, 42, 124, 127, 16, 254, 187, 92, 151, 90, 44, 58, 117
Offset: 0
Links
- Thomas Scheuerle, Table of n, a(n) for n = 0..10000
- Thomas Scheuerle, This sequence shows an extreme chaotic graph.
- Index entries for sequences that are permutations of the natural numbers
Crossrefs
Programs
-
MATLAB
function a = A340069( max_n ) a(1) = 1; n = 2; t = 1; while n <= max_n % search next number t not yet used in a while ~isempty(find(a==t, 1)) t = t+1; end bits1 = length(find(bitget(t,1:32)== 1)); bits2 = length(find(bitget(t*n,1:32)== 1)); if (bits1 == bits2) % we found a candidate a(n) = t; t = 1; n = n+1; else % number t does not yet fit t = t+1; end end end
-
PARI
lista(nn) = {my(va = vector(nn, k, -1)); for (n=0, nn-1, my(k=0); while(! ((hammingweight(k*n) == hammingweight(k)) && !(#select(x->(x==k), va))), k++); va[n+1] = k;); va;} \\ Michel Marcus, Dec 30 2020
-
Python
def binwt(n): return bin(n).count('1') def aupto(n): alst, aset = [], set() for k in range(n+1): ak = 0 while True: while ak in aset: ak += 1 if binwt(ak)==binwt(k*ak): break ak += 1 alst.append(ak) aset.add(ak) return alst print(aupto(72)) # Michael S. Branicky, Jan 02 2021
Formula
a(n) = n if n < 5.
a(2^(2*n)) = 2^(1+n) if n < 5.
a(2^(2*n+1)) = 2^(1+n)+1 if n < 5.
a(3*2^n) = 3*2^(n+1) if n > 0 and < 4.
Comments