A101402 a(0)=0, a(1)=1; for n>=2, let k = smallest power of 2 that is >= n, then a(n) = a(k/2) + a(n-1-k/2).
0, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 21, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 26, 26, 26, 26, 27, 27, 27
Offset: 0
Examples
a(2) = a(1) + a(0) = 1 = 1 + 0; a(3) = a(2) + a(0) = 1 = 1 + 0; a(4) = a(2) + a(1) = 2 = 1 + 1; a(5) = a(4) + a(0) = 2 = 2 + 0; a(6) = a(4) + a(1) = 3 = 2 + 1; a(7) = a(4) + a(2) = 3 = 2 + 1; a(8) = a(4) + a(3) = 3 = 2 + 1; a(9) = a(8) + a(0) = 3 = 3 + 0; ... The terms fall naturally into blocks of sizes 1,1,1,2,4,8,16,32,...: 0, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 14, ... Then the definition says that the k-th block is the final term of the previous block added to the sequence starting from the beginning (e.g., 34445566 = 3 + 01112233). The final terms of the blocks, a(2^k), appear to be given by A164363. - _N. J. A. Sloane_, Aug 27 2014
Links
- Charles R Greathouse IV, Table of n, a(n) for n = 0..10000
- Benoit Jubin, Proof that A101402(n) = Theta(n)
Programs
-
Haskell
import Data.Function (on); import Data.List (genericIndex) a101402 = genericIndex a101402_list a101402_list = 0 : 1 : zipWith ((+) `on` a101402) (tail a053644_list) a053645_list -- Reinhard Zumkeller, Aug 27 2014
-
Mathematica
a[0] = 0; a[1] = 1; a[n_] := a[n] = Block[{p = 2^(Ceiling[Log[2, n]] - 1)}, a[p] + a[n - 1 - p]]; Table[ a@n, {n, 0, 100}] (* Robert G. Wilson v, Aug 17 2009 *)
-
PARI
a(n)=if(n<4, n>0, my(k=2^(log(n-.5)\log(2))); a(k) + a(n-1-k)) \\ Charles R Greathouse IV, Aug 25 2014
Formula
Extensions
Offset corrected by R. J. Mathar, Aug 17 2009
More terms from Robert G. Wilson v, Aug 17 2009
Comments