login
a(n+1) is the number of preceding terms having in binary representation the same number of ones as a(n), starting with a(1) = 1.
5

%I #25 Sep 26 2024 04:10:51

%S 1,1,2,3,1,4,5,2,6,3,4,7,1,8,9,5,6,7,2,10,8,11,3,9,10,11,4,12,12,13,5,

%T 14,6,15,1,13,7,8,14,9,16,15,2,16,17,17,18,19,10,20,21,11,12,22,13,14,

%U 15,3,23,4,18,24,25,16,19,17,26,18,27,5,28,19,20,29,6,30,7,21,22,23,8

%N a(n+1) is the number of preceding terms having in binary representation the same number of ones as a(n), starting with a(1) = 1.

%H Reinhard Zumkeller, <a href="/A137671/b137671.txt">Table of n, a(n) for n = 1..10000</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>.

%F A137672(n) = A000120(a(n)).

%F a(A137673(n)) = n and a(m) < n for m < A137673(n).

%F a(n) = 1 iff a(n-1) = 2^k - 1: a(A137674(n)) = 1.

%e n=4: a(3) = 2 = '10', A000120(2) = 1, therefore: a(4) = #{a(1)=1='1', a(2)=1, a(3)=2='10'} = 3;

%e n=5: a(4) = 3 = '11', A000120(3) = 2, therefore: a(5) = #{a(4)} = 1;

%e n=6: a(5) = 1 = '1', A000120(1) = 1, therefore: a(6) = #{a(1)=1='1', a(2)=1, a(3)=2='10', a(5)} = 4.

%t a[1] = 1; a[n_] := a[n] = Count[Array[s, n-1], s[n-1]]; s[n_] := s[n] = DigitCount[a[n], 2, 1]; Array[a, 100] (* _Amiram Eldar_, Jul 27 2023 *)

%o (PARI) lista(nn) = my(va = vector(nn)); va[1] = 1; for (n=2, nn, va[n] = #select(x->hammingweight(x)==hammingweight(va[n-1]), Vec(va, n-1));); va; \\ _Michel Marcus_, Jul 28 2023

%Y Cf. A000120, A137672, A137673, A137674.

%K nonn,base

%O 1,3

%A _Reinhard Zumkeller_, Feb 05 2008

%E Name edited by _Michel Marcus_, Jul 28 2023