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-2 of 2 results.

A144078 a(n) = the number of digits in the binary representation of n that differ from the corresponding digit in the binary reversal of n. (I.e., a(n) = number of 1's in n XOR A030101(n).)

Original entry on oeis.org

0, 2, 0, 2, 0, 2, 0, 2, 0, 4, 2, 4, 2, 2, 0, 2, 0, 4, 2, 2, 0, 4, 2, 4, 2, 2, 0, 4, 2, 2, 0, 2, 0, 4, 2, 4, 2, 6, 4, 4, 2, 6, 4, 2, 0, 4, 2, 4, 2, 2, 0, 6, 4, 4, 2, 6, 4, 4, 2, 4, 2, 2, 0, 2, 0, 4, 2, 4, 2, 6, 4, 2, 0, 4, 2, 4, 2, 6, 4, 4, 2, 6, 4, 2, 0, 4, 2, 4, 2, 6, 4, 2, 0, 4, 2, 4, 2, 2, 0, 6, 4, 4, 2, 4, 2
Offset: 1

Views

Author

Leroy Quet, Sep 09 2008

Keywords

Comments

a(n) + A144079(n) = A070939(n), the number of binary digits in n.

Examples

			20 in binary is 10100. Compare this with its digit reversal, 00101. XOR each pair of corresponding digits: 1 XOR 0 = 1, 0 XOR 0 = 0, 1 XOR 1 = 0, 0 XOR 0 = 0, 0 XOR 1 = 1. There are two bit pairs that differ, so a(20) = 2.
		

Crossrefs

Programs

  • Maple
    A144078 := proc(n) local a,dgs,i; a := 0 ; dgs := convert(n,base,2) ; for i from 1 to nops(dgs) do if op(i,dgs)+op(-i,dgs) = 1 then a := a+1 ; fi; od; RETURN(a) ; end: for n from 1 to 240 do printf("%d,",A144078(n)) ; od: # R. J. Mathar, Sep 14 2008
  • Mathematica
    brd[n_]:=Module[{idn2=IntegerDigits[n,2]},Count[Transpose[{idn2, Reverse[ idn2]}], ?(#[[1]]!=#[[2]]&)]]; Array[brd,110] (* _Harvey P. Dale, May 09 2016 *)
  • PARI
    a(n) = hammingweight(bitxor(n, fromdigits(Vecrev(binary(n)),2))) \\ Rémy Sigrist, Oct 07 2018

Formula

From Rémy Sigrist, Oct 07 2018: (Start)
a(n) = 0 iff n is a binary palindrome (A006995).
a(A143960(n)) = 2*n (in fact A143960(n) is the least k such that a(k) = 2*n).
(End)

Extensions

More terms from R. J. Mathar, Sep 14 2008

A377192 Smallest number with the property that you have to change at least n digits to get a palindrome.

Original entry on oeis.org

0, 10, 1010, 100110, 10001110, 1000011110, 100000111110, 10000001111110, 1000000011111110, 100000000111111110, 10000000001111111110, 1000000000011111111110, 100000000000111111111110, 10000000000001111111111110, 1000000000000011111111111110, 100000000000000111111111111110
Offset: 0

Views

Author

Franz Vrabec, Oct 19 2024

Keywords

Comments

Positions of records in A377191.

Examples

			a(2) = 1010 because 1010 is the smallest number with the property that you have to change at least 2 digits to get a palindrome.
		

Crossrefs

Programs

  • Mathematica
    A377192[n_] := Ceiling[10^(2*n-1) + (10^n-1)/9 - 1]; Array[A377192, 20, 0] (* or *)
    LinearRecurrence[{111, -1110, 1000}, {0, 10, 1010, 100110}, 20] (* Paolo Xausa, Nov 06 2024 *)

Formula

a(n) = 10^(2*n-1) + (10^n-1)/9 - 1 for n > 0.
From Stefano Spezia, Oct 20 2024: (Start)
G.f.: 10*x*(1 - 10*x - 90*x^2)/((1 - x)*(1 - 10*x)*(1 - 100*x)).
E.g.f.: (81 - 100*exp(x) + 10*exp(10*x) + 9*exp(100*x))/90. (End)
a(n) = A007088(A143960(n)) for n > 0. - Rémy Sigrist, Nov 05 2024
Showing 1-2 of 2 results.