login
a(n) = a(n-1) + a(m) for n >= 4, where m = n - 1 - 2^p and p is the unique integer such that 2^p < n - 1 <= 2^(p+1), starting with a(1) = 1 and a(2) = a(3) = 2.
4

%I #16 Apr 24 2020 02:11:17

%S 1,2,2,3,5,6,8,10,13,14,16,18,21,26,32,40,50,51,53,55,58,63,69,77,87,

%T 100,114,130,148,169,195,227,267,268,270,272,275,280,286,294,304,317,

%U 331,347,365,386,412,444

%N a(n) = a(n-1) + a(m) for n >= 4, where m = n - 1 - 2^p and p is the unique integer such that 2^p < n - 1 <= 2^(p+1), starting with a(1) = 1 and a(2) = a(3) = 2.

%H Ivan Neretin, <a href="/A050046/b050046.txt">Table of n, a(n) for n = 1..8193</a>

%p a := proc(n) option remember;

%p `if`(n < 4, [1, 2, 2][n], a(n - 1) + a(-2^ceil(-1+log[2](n - 1)) + n - 1)):

%p end proc:

%p seq(a(n), n = 1..40); # _Petros Hadjicostas_, Apr 23 2020

%t Fold[Append[#1, #1[[-1]] + #1[[#2]]] &, {1, 2, 2}, Flatten@Table[k, {n, 5}, {k, 2^n}]] (* _Ivan Neretin_, Sep 08 2015 *)

%Y Cf. similar sequences listed in A050034.

%K nonn

%O 1,2

%A _Clark Kimberling_

%E Name edited by _Petros Hadjicostas_, Apr 23 2020