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.

Showing 1-5 of 5 results.

A206913 Greatest binary palindrome <= n; the binary palindrome floor function.

Original entry on oeis.org

0, 1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 9, 9, 9, 9, 15, 15, 17, 17, 17, 17, 21, 21, 21, 21, 21, 21, 27, 27, 27, 27, 31, 31, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 45, 45, 45, 45, 45, 45, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 63, 63, 65, 65, 65, 65
Offset: 0

Views

Author

Hieronymus Fischer, Feb 13 2012

Keywords

Comments

Also the greatest binary palindrome < n + 1;
For n > 0, a(n-1) is the greatest binary palindrome < n.

Examples

			a(0) = 0 since 0 is the greatest binary palindrome <= 0;
a(1) = 1 since 1 is the greatest binary palindrome <= 1;
a(2) = 1 since 1 is the greatest binary palindrome <= 2;
a(3) = 3 since 3 is the greatest binary palindrome <= 3.
		

Crossrefs

Sequences related to palindromic floor and ceiling: A175298, A206913, A206914, A261423, A262038, and the large block of consecutive sequences beginning at A265509.

Programs

  • Haskell
    a206913 n = last $ takeWhile (<= n) a006995_list
    -- Reinhard Zumkeller, Feb 27 2012

Formula

Let n > 2, p = 1 + 2*floor((n-1)/2), m = floor(log_2(p)), q = floor((m+1)/2), s = floor(log_2(p-2^q)),
F(x, r) = floor(x/2^q)*2^q + Sum_{k = 0...q - 1} (floor(x/2^(r-k)) mod 2)*2^k;
If F(p, m) <= n then a(n) = F(p, m), otherwise a(n) = F(p-2^q, s).
By definition: F(p, m) = floor(p/2^q)*2^q + A030101(p) mod 2^q; also: F(p-2^q, s) = floor((p-2^q)/2^q)*2^q + A030101(p-2^q) mod 2^q; [Edited and corrected by Hieronymus Fischer, Sep 08 2018]
a(n) = A006995(A206915(n));
a(n) = A006995(A206915(A206914(n+1))-1);
a(n) = A006995(A206916(A206914(n+1))-1).

A206914 Least binary palindrome >= n; the binary palindrome ceiling function.

Original entry on oeis.org

0, 1, 3, 3, 5, 5, 7, 7, 9, 9, 15, 15, 15, 15, 15, 15, 17, 17, 21, 21, 21, 21, 27, 27, 27, 27, 27, 27, 31, 31, 31, 31, 33, 33, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 51, 51, 51, 51, 51, 51, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 65, 73, 73
Offset: 0

Views

Author

Hieronymus Fischer, Feb 15 2012

Keywords

Comments

For n > 0 also the least binary palindrome > n - 1;
a(n+1) is the least binary palindrome > n

Examples

			a(0) = 0 since 0 is the least binary palindrome >= 0;
a(1) = 1 since 1 is the least binary palindrome >= 1;
a(2) = 3 since 3 is the least binary palindrome >= 2;
a(5) = 5 since 5 is the least binary palindrome >= 5;
		

Crossrefs

Sequences related to palindromic floor and ceiling: A175298, A206913, A206914, A261423, A262038, and the large block of consecutive sequences beginning at A265509.

Programs

  • Haskell
    a206914 n = head $ dropWhile (< n) a006995_list
    -- Reinhard Zumkeller, Feb 27 2012

Formula

a(n) = A006995(A206916(n));
a(n) = A006995(A206916(A206913(n-1))+1);
a(n) = A006995(A206915(A206913(n-1))+1);

A206915 The index (in A006995) of the greatest binary palindrome <= n; also the 'lower inverse' of A006995.

Original entry on oeis.org

1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 16, 16, 16, 16, 16, 16, 16
Offset: 0

Views

Author

Hieronymus Fischer, Feb 15 2012

Keywords

Comments

The greatest m such that A006995(m)<= n;
The number of binary palindromes <= n;
n is palindromic iff a(n)=A206916(n);
a(n) is the number of the binary palindrome A206913(n);
if n is a binary palindrome, then A006995(a(n))=n, so a(n) is 'inverse' with respect to A006995.
Partial sums of the binary palindromic characteristic function A178225.

Examples

			a(1)=2 since 2 is the index number of the greatest binary palindrome <= 1;
a(5)=4 since there are only 4 binary palindromes (namely 0,1,3 and 5) which are less than or equal to 5;
a(10)=6 since A006995(6)=9<=10, but A006995(7)=15>10, and so that, 6 is the index number of greatest binary palindrome <= 10;
		

Crossrefs

Programs

  • Mathematica
    A178225[n_]:=Boole[PalindromeQ[IntegerDigits[n,2]]];
    Accumulate[Array[A178225,100,0]] (* Paolo Xausa, Oct 15 2023 *)
  • Python
    def A206915(n):
        l = n.bit_length()
        k = l+1>>1
        return (n>>l-k)-(int(bin(n)[k+1:1:-1] or '0',2)>(n&(1<Chai Wah Wu, Jul 24 2024

Formula

a(n) = max(m | A006995(m) <= n);
a(A006995(n)) = n;
A006995(a(n)) <= n, equality holds true iff n is a binary palindrome;
Let p = A206913(n), m = floor(log_2(p)) and p>2, then:
a(n) = (((5-(-1)^m)/2) + sum_{k=1..floor(m/2)} (floor(p/2^k) mod 2)/2^k)) * 2^floor(m/2).
a(n) = (1/2)*((6-(-1)^m)*2^floor(m/2) - 1 - sum_{k=1..floor(m/2)} (-1)^floor(p/2^k) * 2^(floor(m/2)-k))).
a(n) = (5-(-1)^m) * 2^floor(m/2)/2 - 3*sum_{k=2..floor(m/2)} (floor(p/2^k) * 2^floor(m/2)/2^k) + (floor(p/2) * 2^floor(m/2)/2 - 2*floor((p/2) * 2^floor(m/2)) * floor((m-1)/m+1/2).
Partial sums S(n) = sum_{k=0..n} a(k):
S(n) = (n+1)*a(n) - A206920(a(n)).
G.f.: g(x) = (1+x+x^3+sum_{j>=1} x^(3*2^j)*(f_j(x)+f_j(1/x)))/(1-x), where the f_j(x) are defined as follows:
f_1(x) = x, and for j>1,
f_j(x) = x^3*product_{k=1..floor((j-1)/2)} (1+x^b(j,k)), where b(j,k)=2^(floor((j-1)/2)-k)*((3+(-1)^j)*2^(2*k+1)+4) for k>1, and b(j,1)=(2+(-1)^j)*2^(floor((j-1)/2)+1).

A206916 Index of the least binary palindrome >=n; also the "upper inverse" of A006995.

Original entry on oeis.org

1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 17, 17, 17, 17, 17
Offset: 0

Views

Author

Hieronymus Fischer, Feb 17 2012

Keywords

Comments

The least m such that A006995(m)>=n;
n is palindromic iff a(n)=A206915(n);
a(n) is the number of the binary palindrome A206914(n);
if n is a binary palindrome, then A006995(a(n))=n, so a(n) is 'inverse' with respect to A006995

Examples

			a(2)=3 since 3 is the index number of the least binary palindrome >= 2;
a(5)=4 since 4 is the index number of the least binary palindrome >= 5;
a(10)=7 since A006995(7)=15>=10, but A006995(6)=9<10, and so that, 7 is the index number of least binary palindrome >= 10;
		

Crossrefs

Programs

  • Python
    def A206916(n):
        l = n.bit_length()
        k = l+1>>1
        return (n>>l-k)+(int(bin(n)[k+1:1:-1] or '0',2)<(n&(1<Chai Wah Wu, Jul 24 2024

Formula

a(n)=min(m|A006995(m)>=n);
a(A006995(n))=n;
A006995(a(n))>=n, equality holds true iff n is a binary palindrome;
Let p=A206914(n), m=floor(log_2(p)) and p>2, then:
a(n)=(((5-(-1)^m)/2) + sum_{k=1..floor(m/2)} (floor(p/2^k) mod 2)/2^k))*2^floor(m/2);
a(n)=(1/2)*((6-(-1)^m)*2^floor(m/2)-1-sum_ {k=1..floor(m/2)} (-1)^floor(p/2^k)*2^(floor(m/2)-k)));
a(n)=(5-(-1)^m)*2^floor(m/2)/2-3*sum_{k=2..floor(m/2)} floor(p/2^k)*2^floor(m/2)/2^k)+(floor(p/2)*2^floor(m/2)/2-2*floor((p/2)*2^floor(m/2))*floor((m-1)/m+1/2).
Partial sums S(n) = sum_{k=0..n} a(k):
S(n) = 1+n*a(n)-A206920(a(n)-1), valid for n>0.
G.f.: g(x)=(x+x^2+x^3+sum_{j=1..infinity} x^(3*2^j)*(f_j(x)+f_j(1/x)))/(x(1-x)), where the f_j(x) are defined as follows:
f_1(x)=x, and for j>1,
f_j(x)=x^3*product_{k=1..floor((j-1)/2)} (1+x^b(j,k)), where b(j,k)=2^(floor((j-1)/2)-k)*((3+(-1)^j)*2^(2*k+1)+4) for k>1, and b(j,1)=(2+(-1)^j)*2^(floor((j-1)/2)+1).

A206919 Sum of binary palindromes <= n.

Original entry on oeis.org

0, 1, 1, 4, 4, 9, 9, 16, 16, 25, 25, 25, 25, 25, 25, 40, 40, 57, 57, 57, 57, 78, 78, 78, 78, 78, 78, 105, 105, 105, 105, 136, 136, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 214, 214, 214, 214, 214, 214, 265, 265, 265, 265, 265, 265, 265, 265
Offset: 0

Views

Author

Hieronymus Fischer, Feb 18 2012

Keywords

Comments

Sum of binary palindromes A006995(k) <= n.
Different from A206920.

Examples

			a(2)=1, since the only binary palindromes <= 1 are p=0 and p=1;
a(5)=9, since the sum of all binary palindromes <= 5 is 9 = 0 + 1 + 3 + 5.
		

Crossrefs

Programs

  • PARI
    a(n) = sum(k=1, n, my(b=binary(k)); if (b==Vecrev(b), k)); \\ Michel Marcus, Sep 09 2018

Formula

a(n) = Sum_{k=1..A206915(A206913(n))} A006995(k).
a(n) = A206920(A206915(A206913(n))).
Let p = A206913(n) > 3, 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 08 2018]
Showing 1-5 of 5 results.