A178225 Characteristic function of A006995 (binary palindromes).
1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0
Offset: 0
Examples
a(3)=1, since 3 is binary palindromic; a(4)=0, since 4 is not palindromic.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
- Index entries for characteristic functions
Programs
-
Haskell
a178225 n = fromEnum $ n == a030101 n -- Reinhard Zumkeller, Oct 21 2011
-
Mathematica
A178225[n_]:=Boole[PalindromeQ[IntegerDigits[n,2]]]; Array[A178225,100,0] (* Paolo Xausa, Oct 15 2023 *)
-
PARI
a(n) = my(b=binary(n)); b == Vecrev(b); \\ Michel Marcus, Feb 13 2019
-
Python
a187225 = lambda n: int(bin(n)[2:] == bin(n)[:1:-1]) # David Radcliffe, May 05 2023
Formula
a(n) = if A030101(n) = n then 1, otherwise 0. - Reinhard Zumkeller, Jan 17 2012
G.f.: g(x) = 1 + x + x^3 + Sum{j>=1} x^(3*2^j)*(f_j(x)+f_j(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). The first explicit terms of this g.f. are
g(x) = 1 + x + x^3 + (f_1(x) + f_1(1/x))*x^6 + (f_2(x) + f_2(1/x))*x^12 + (f_3(x)+f_3(1/x))*x^24 + (f_4(x) + f_4(1/x))*x^48 + (f_5(x) + f_5(1/x))*x^96 + ... = 1 + x + x^3 + (x+1/x)*x^6 + (x^3+1/x^3)*x^12 + (x^3*(1+x^4) + (1+1/x^4)/x^3)*x^24 + (x^3*(1+x^12) + (1+1/x^12)/x^3)*x^48 + (x^3*(1+x^8)(1+x^20) + (1+1/x^20)(1+1/x^8)/x^3)*x^96 + ... - Hieronymus Fischer, Apr 02 2012
Comments