%I #23 May 24 2024 01:36:43
%S 1,3,5,7,2,9,11,13,15,17,4,19,6,8,21,23,10,25,27,29,31,12,33,35,37,39,
%T 41,43,14,16,18,45,47,20,22,49,24,26,51,53,55,57,28,59,30,32,34,61,36,
%U 63,38,65,67,40,69,71,73,75,42,77,44,79,81,46,48,83,85,87,50,89,91,93,95
%N Lexicographically earliest sequence of distinct positive integers such that the parity of the successive bits of the concatenated binary expansions of the terms is equal to the parity of the terms.
%C The concatenated binary expansions of the terms act as instructions to take the next unused odd or even number.
%C This is a permutation of the positive integers.
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%e terms 1 3 5 7 2 9
%e binary {1}, {1, 1}, {1, 0, 1}, {1, 1, 1}, {1, 0}, {1, 0, 0, 1}
%e terms 1, 3, 5, 7, 2, 9, 11,13,15, 17, 4, 19, 6, 8,21
%e n = 1 2 3 4 5 6 7 8 9 10 11 ...
%e a(11) = 4 because the 11th bit in the binary expansions is 0 (from term a(5)=2 as it happens) which means a(11) must be even and 4 is the least even positive integer not yet in the sequence.
%t a[1]=1;a[n_]:=a[n]=(k=1;While[MemberQ[Array[a,n-1],k]||Boole@OddQ@k!= Flatten[IntegerDigits[Join[Array[a,n-1],{k}],2]][[n]],k++];k);Array[a,73]
%o (Python)
%o from itertools import count, islice
%o def agen(): # generator of terms
%o an, parity, nextk = 1, [None, 1, 1, 1], [2, 5]
%o yield from [1, 3]
%o for n in count(3):
%o an = nextk[parity[n]]
%o yield an
%o nextk[parity[n]] = nextk[parity[n]] + 2
%o parity.extend(map(int, bin(an)[2:]))
%o print(list(islice(agen(), 73))) # _Michael S. Branicky_, Feb 01 2024
%Y Cf. A030190.
%K nonn,base
%O 1,2
%A _Giorgos Kalogeropoulos_, Feb 01 2024