login
a(n) = A002487(1+A005187(n)).
7

%I #10 May 05 2023 12:35:56

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

%T 1,7,11,5,13,4,11,18,13,3,11,19,13,18,17,12,11,2,9,16,12,17,18,13,11,

%U 14,13,10,18,11,4,13,1,8,13,6,16,5,14,23,17,4,15,26,18,25,24,17,16,3,14,25,19,27,29,21,18,23,22,17,31,19,7,23,13,2

%N a(n) = A002487(1+A005187(n)).

%H Antti Karttunen, <a href="/A324288/b324288.txt">Table of n, a(n) for n = 0..16384</a>

%H Antti Karttunen, <a href="/A324288/a324288.txt">Data supplement: n, a(n) computed for n = 0..65537</a>

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

%H <a href="/index/St#Stern">Index entries for sequences related to Stern's sequences</a>

%F a(n) = A002487(1+A005187(n)).

%o (PARI)

%o A002487(n) = { my(s=sign(n), a=1, b=0); n = abs(n); while(n>0, if(bitand(n, 1), b+=a, a+=b); n>>=1); (s*b); }; \\ Modified from the one given in A002487, sign not actually needed here.

%o A005187(n) = { my(s=n); while(n>>=1, s+=n); s; };

%o A324288(n) = A002487(1+A005187(n));

%o (Python)

%o from functools import reduce

%o def A324288(n): return sum(reduce(lambda x,y:(x[0],x[0]+x[1]) if int(y) else (x[0]+x[1],x[1]),bin(1+(n<<1)-n.bit_count())[-1:2:-1],(1,0))) if n else 1 # _Chai Wah Wu_, May 05 2023

%Y Cf. A002487, A005187, A324287, A324116.

%K nonn

%O 0,4

%A _Antti Karttunen_, Feb 20 2019