login
a(1)=1; thereafter a(n) = smallest positive integer not among the earlier terms of the sequence such that a(n) and a(n-1) have floor(k/2) common 1-bits in their binary representations, where k is the number of bits in the binary representation of a(n-1).
2

%I #23 Dec 30 2024 13:42:56

%S 1,2,3,5,4,6,10,11,7,9,13,12,14,22,15,19,17,21,20,23,18,26,24,25,28,

%T 27,35,39,31,37,45,29,41,43,42,46,30,38,47,44,60,52,53,49,51,50,54,58,

%U 55,57,56,59,75,63,71,67,79,61,77,69,85,81,83,82,86,62,78,70

%N a(1)=1; thereafter a(n) = smallest positive integer not among the earlier terms of the sequence such that a(n) and a(n-1) have floor(k/2) common 1-bits in their binary representations, where k is the number of bits in the binary representation of a(n-1).

%C A variant of A109812. Sharing floor(k/2) common 1-bits is akin to minimal or zero correlation between sequences whose elements are in {+1,-1}.

%H Rémy Sigrist, <a href="/A352715/b352715.txt">Table of n, a(n) for n = 1..10000</a>

%H Rémy Sigrist, <a href="/A352715/a352715.gp.txt">PARI program</a>

%o (PARI) \\ See Links section.

%o (Python)

%o from itertools import islice

%o def A352715_gen(): # generator of terms

%o yield 1

%o l1, s, b, bli = 1, 2, set(), 0

%o while True:

%o i = s

%o while True:

%o if not (i in b or (i & l1).bit_count() != bli):

%o yield i

%o l1 = i

%o bli = l1.bit_length()//2

%o b.add(i)

%o while s in b:

%o b.remove(s)

%o s += 1

%o break

%o i += 1

%o A352715_list = list(islice(A352715_gen(),20)) # _Chai Wah Wu_, Apr 02 2022

%Y Cf. A109812.

%K nonn

%O 1,2

%A _Chai Wah Wu_, _Michael De Vlieger_, _Rémy Sigrist_, and _N. J. A. Sloane_, Mar 30 2022.