The sequence is defined as $a(1)=1,a(n)=a(n-1)+a\left(\left\lfloor \log _2(n)\right\rfloor \right)$
A natural way do this is
ClearAll[a];
a[1] = 1;
a[n_] := a[n] = a[n - 1] + a[Floor@Log2@N@n];
Table[a[i], {i, 1, 2^20}]; // AbsoluteTiming
It's not very quickly enough. I think there is a iteration solution using Nest
or Fold
,but I can't get it.
BitLength@n-1
instead ofFloor@Log2@N@n
$\endgroup$ – Lukas Lang Aug 25 '17 at 7:29