OFFSET
0,3
COMMENTS
I would call this sequence "the evil beast" because it shows many patterns, but for each pattern there seems to be a value of n at which the rules change suddenly or some unexpected exceptions occur.
If n is a power of 2 any number satisfies the condition as the number of 1-bits does not change by multiplication by a power of 2. Because of this every number eventually has a chance to appear in this sequence; this proves that this sequence is a permutation of the nonnegative integers.
This sequence may have applications in finding small pairs of b and c such that A000120(b)=A000120(c*b), because A000120(a(n))=A000120(a(n)*n).
In the range n = 0..100000 the largest value a(n) is 131072 = a(32769), but the smallest value in the range n = 30000..40000 is a(32768) = 137.
If A000120(b)=A000120(c*b) then A000120(b*2^d)=A000120(c*b*2^d); this causes some patterns in this sequence which may be valid in a limited range of n. Can we find one which is valid for a large range of values of n?
If a(n) is a power of two, then n is a power of two as well. But if n is a power of two, a(n) is not always a power of two.
In equations of the form A000120(c)=A000120(c*b) for all A000120(c)=2 we find all solutions for b as b=0, b=2^d or b=(2^d)*(1+2^(((c-1)/2)+e*(c-1)))/c, if c is odd. For even c divide c by largest possible power of two. An example for c=3 is b=A263132.
a(n) >= A292849(n). This lower bound is responsible for some of the peaks in this sequence.
LINKS
Thomas Scheuerle, Table of n, a(n) for n = 0..10000
Thomas Scheuerle, This sequence shows an extreme chaotic graph.
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.
PROG
(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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Thomas Scheuerle, Dec 28 2020
STATUS
approved