cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A206920 Sum of the first n binary palindromes; a(n) = Sum_{k=1..n} A006995(k).

Original entry on oeis.org

0, 1, 4, 9, 16, 25, 40, 57, 78, 105, 136, 169, 214, 265, 328, 393, 466, 551, 644, 743, 850, 969, 1096, 1225, 1378, 1543, 1732, 1927, 2146, 2377, 2632, 2889, 3162, 3459, 3772, 4097, 4438, 4803, 5184, 5571, 5974, 6401, 6844, 7299, 7770, 8265, 8776, 9289, 9850
Offset: 1

Views

Author

Hieronymus Fischer, Feb 18 2012

Keywords

Comments

Different from A206919.

Examples

			a(1) = 0, since A006995(1) = 0;
a(4) = 9, since the sum of the first 4 binary palindromes is 9 = 0 + 1 + 3 + 5.
		

Crossrefs

Programs

  • Haskell
    a206920 n = a206920_list !! (n-1)
    a206920_list = scanl1 (+) a006995_list
    -- Reinhard Zumkeller, Feb 27 2012
  • Mathematica
    Accumulate@ Map[FromDigits[#, 2] &, Select[Array[IntegerDigits[#, 2] &, 600, 0], PalindromeQ]] (* Michael De Vlieger, Feb 20 2018 *)

Formula

Let n > 3, p = A006995(n), m = floor(log_2(p)), then
a(n) = (8/7)*((3/4)*(4 - (-1)^m)/(3 + (-1)^m)*2^(3*floor(m/2)) - 1) + (floor(p/2^floor(m/2)) mod 2)*p + 2^m + 1 + Sum_{k = 1..(floor(m/2) - 1)} (floor(p/2^k) mod 2)*(2^k + 2^(m-k) + 2^(m-floor(m/2) + 1)*(4^(floor(m/2) - k - 1) - 1) + (2 - (-1)^m)*2^floor(m/2) + 2^(floor(m/2) - k)*(p - floor((p mod (2^(m-k+1)))/2^k)*2^k)). - [Corrected; missing factor to the sum term (2 -(-1)^m) pasted by the author, Sep 07 2018]
From Hieronymus Fischer, Sep 07 2018: (Start)
Slightly simplified and better readable formula:
a(n) = A_m + B_m + 2^m + 1 + Sum_{k = 1..(m2-1)} C_k*(D_k + E_k + F_k + G_k),
where m2 = floor(m/2),
A_m = (8/7)*((3/4)*(4-(-1)^m)/(3+(-1)^m)*2^(3*m2)-1),
B_m = p*(floor(p/2^m2) mod 2),
C_k = floor(p/2^k) mod 2,
D_k = 2^k + 2^(m-k),
E_k = 2^(m-m2+1)*(4^(m2-k-1)-1),
F_k = (2 - (-1)^m)*2^m2,
G_k = 2^(m2-k) * (p - p mod (2^(m-k+1)) + p mod 2^k). (End)
G.f.: g(x) = (x^2 + 3x^3 + Sum_{j >= 1} (3*2^j*(1 - x^floor((j+1)/2))/(1-x)*x^((1/2) - floor((j+1)/2)) + f_j(x) - f_j(1/x))*x^(2*2^floor(j/2) + 3*2^floor((j-1)/2) - (1/2)))/(1-x), where the f_j(x) are the same as defined for the g.f. of A006995.