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

A215469 a(n) = A215467(2n+1).

Original entry on oeis.org

1, 2, 3, 3, 4, 3, 2, 4, 5, 4, 5, 3, 2, 5, 3, 5, 6, 5, 4, 4, 3, 5, 6, 3, 2, 6, 2, 5, 3, 3, 4, 6, 7, 6, 5, 5, 7, 4, 4, 4, 3, 3, 7, 5, 3, 6, 7, 3, 2, 7, 2, 6, 2, 7, 5, 5, 3, 3, 3, 7, 4, 4, 5, 7, 8, 7, 6, 6, 5, 5, 5, 5, 4, 7, 4, 4, 8, 4, 4, 4, 3, 3, 8, 3, 5, 7, 5, 5, 3, 3, 6, 6, 3, 7, 8, 3, 2, 8, 2, 7
Offset: 0

Views

Author

N. J. A. Sloane, Aug 11 2012

Keywords

Comments

The other bisection of A215467, {A215467(2n)}, is the same as A215467 itself.

Crossrefs

Cf. A215467.

A050430 Length of longest palindromic subword of (n base 2).

Original entry on oeis.org

1, 1, 2, 2, 3, 2, 3, 3, 4, 3, 3, 2, 3, 3, 4, 4, 5, 4, 4, 3, 5, 4, 3, 3, 4, 3, 5, 3, 3, 4, 5, 5, 6, 5, 5, 5, 4, 4, 4, 3, 4, 5, 5, 4, 6, 5, 4, 4, 5, 4, 6, 3, 5, 5, 5, 3, 4, 3, 5, 4, 4, 5, 6, 6, 7, 6, 6, 5, 5, 5, 5, 5, 7, 5, 4, 6, 4, 5, 4, 4, 5, 6, 4, 5, 7, 5, 5, 4, 4, 6, 6, 5, 7, 6, 5, 5, 6, 5, 7, 5, 4, 6, 6, 3, 4
Offset: 1

Views

Author

Keywords

Comments

a(A083318(n-1)) = n; a(A193159(k)) = 3, 1 <= k <= 26. [Reinhard Zumkeller, Jul 17 2011]

Examples

			(11 base 2) = 1011, containing the palindrome 101, therefore a(11) = 3.
		

Crossrefs

Cf. A007088; A050431 (base 3), A050432 (base 4), A050433 (base 5).

Programs

  • Haskell
    import Data.Char (intToDigit, digitToInt)
    import Numeric (showIntAtBase)
    a050430 n = a050430_list !! (n-1)
    a050430_list = f 1 where
       f n = g (showIntAtBase 2 intToDigit n "") : f (n+1)
       g zs | zs == reverse zs = length zs
            | otherwise        = max (h $ init zs) (h $ tail zs)
       h zs@('0':_) = g zs
       h zs@('1':_) = a050430 $ foldl (\v d -> digitToInt d + 2*v) 0 zs
    -- Reinhard Zumkeller, Jul 16 2011
  • Maple
    # A050430 Length of longest palindromic factor of n for n in [M1..M2] - from N. J. A. Sloane, Aug 07 2012, revised Aug 11 2012
    isPal := proc(L)
        local d ;
        for d from 1 to nops(L)/2 do
            if op(d, L) <> op(-d, L) then
                return false;
            end if;
        end do:
        return true;
    end proc:
    # start of main program
    ans:=[];
    M1:=0; M2:=64;
    for n from M1 to M2 do
    t1:=convert(n,base,2);
    rec:=0:
    l1:=nops(t1);
    for j1 from 0 to l1-1 do
    for j2 from j1+1 to l1 do
    F1 := [op(j1+1..j2,t1)];
    if (isPal(F1) and j2-j1>rec) then rec:=j2-j1; fi;
    od:
    od:
    ans:=[op(ans),rec]:
    od:
    ans;
  • Mathematica
    f[n_] := Block[{id = IntegerDigits[n, 2]}, k = Length@ id; While[ Union[# == Reverse@# & /@ Partition[id, k, 1]][[-1]] != True, k--]; k]; Array[f, 105] (* Robert G. Wilson v, Jul 16 2011 *)

Formula

a(n) <= min(a(2*n), a(2*n+1)). [Reinhard Zumkeller, Jul 31 2011]

Extensions

Extended by Ray Chandler, Mar 11 2010

A215256 Longest palindromic factor of (n base 2); in case of tie choose largest; if it begins with 0 complement it.

Original entry on oeis.org

1, 1, 1, 11, 11, 101, 11, 111, 111, 1001, 101, 101, 11, 101, 111, 1111, 1111, 10001, 1001, 1001, 101, 10101, 1001, 111, 111, 1001, 101, 11011, 111, 111, 1111, 11111, 11111, 100001, 10001, 10001, 11011, 1001, 1001, 1001, 101, 1001, 10101, 10101, 1001, 101101
Offset: 0

Views

Author

N. J. A. Sloane, Aug 15 2012

Keywords

Comments

The "if it begins with 0 complement it" clause is required because nonzero terms in the OEIS may not begin with 0.

Examples

			n=10 = 1010, longest palindromic factor is 101.
n=12 = 1100, there are two palindromic factors of length 2, namely 11 and 00, and we choose the larger, 11.
n=24 = 11000, longest palindromic factor is 000, complementing gives 111.
		

Crossrefs

Extensions

More terms from Lars Blomberg, Jun 29 2014

A330717 a(n) is the greatest binary palindrome of the form floor(n/2^k) with k >= 0.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Dec 28 2019

Keywords

Comments

In other words, a(n) is the greatest binary palindromic prefix of n.

Examples

			The first terms, alongside the binary representations of n and of a(n), are:
  n   a(n)  bin(n)  bin(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     1       1          1
   2     1      10          1
   3     3      11         11
   4     1     100          1
   5     5     101        101
   6     3     110         11
   7     7     111        111
   8     1    1000          1
   9     9    1001       1001
  10     5    1010        101
  11     5    1011        101
		

Crossrefs

Programs

  • PARI
    a(n,b=2) = { my (d=digits(n,b)); forstep (w=#d, 1, -1, my (h=d[1..w]); if (h==Vecrev(h), return (fromdigits(h, b)))); return (0) }

Formula

A070939(a(n)) = A215467(n).
a(n) = 1 iff n is a power of 2.
a(n) <= n with equality iff n is a binary palindrome (A006995).
a(a(n)) = a(n).
a(2*n) = a(n).
Showing 1-4 of 4 results.