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-10 of 13 results. Next

A215244 a(n) is the number of ways of writing the binary expansion of n as a product (or concatenation) of palindromes.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Aug 07 2012

Keywords

Comments

"Product" is used here is the usual sense of combinatorics on words.
The sequence may be arranged into a triangle in which row k contains the 2^k terms [a(2^k), ..., a(2^(k+1)-1)]: (1), (1), (1,2), (2,2,2,4), ... The row sums of this triangle appear to be A063782. - R. J. Mathar, Aug 09 2012. I have a proof that A063782 does indeed give the row sums. - N. J. A. Sloane, Aug 10 2012
a(A220654(n)) = n and a(m) < n for m < A220654(n). - Reinhard Zumkeller, Dec 17 2012

Examples

			a(4)=2 since 4 = 100, and 100 can be written as either 1.0.0 or 1.00.
a(5)=2 from 1.0.1, 101.
a(10)=3 from 1.0.1.0, 1.010, 101.1
Written as a triangle, the sequence is:
1,
1,
1, 2,
2, 2, 2, 4,
4, 3, 3, 3, 4, 3, 4, 8,
8, 5, 4, 5, 5, 5, 4, 6, 8, 5, 5, 6, 8, 6, 8, 16,
16, 9, 7, 9, 8, 6, 6, 10, 10, 6, 8, 8, 7, 7, 7, 12, 16, 9, 7, 10, 8, 8, 8, 11, 16, 10, 10, 11, 16, 12, 16, 32,
...
		

Crossrefs

Programs

  • Haskell
    import Data.Map (Map, singleton, (!), insert)
    import Data.List (inits, tails)
    newtype Bin = Bin [Int] deriving (Eq, Show, Read)
    instance Ord Bin where
       Bin us <= Bin vs | length us == length vs = us <= vs
                        | otherwise              = length us <= length vs
    a215244 n = a215244_list !! n
    a215244_list = 1 : f [1] (singleton (Bin [0]) 1) where
       f bs m | last bs == 1 = y : f (succ bs) (insert (Bin bs) y m)
              | otherwise    = f (succ bs) (insert (Bin bs) y m) where
         y = fromEnum (pal bs) +
             sum (zipWith (\us vs -> if pal us then m ! Bin vs else 0)
                          (init $ drop 1 $ inits bs) (drop 1 $ tails bs))
         pal ds = reverse ds == ds
         succ [] = [0]; succ (0:ds) = 1 : ds; succ (1:ds) = 0 : succ ds
    -- Reinhard Zumkeller, Dec 17 2012
  • Maple
    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:
    A215244L := proc(L)
        local a,c;
        a := 0 ;
        if isPal(L) then
            a := 1;
        end if;
        for c from 1 to nops(L)-1 do
            if isPal( [op(1..c,L)] ) then
                a := a+procname([op(c+1..nops(L),L)]) ;
            end if;
        end do:
        return a;
    end proc:
    A215244 := proc(n)
        if n = 1 then
            1;
        else
            convert(n,base,2) ;
            A215244L(%) ;
        end if;
    end proc: # R. J. Mathar, Aug 07 2012
    # Caution: the last procedure applies A215244L to the reverse of the binary expansion of n, which is perfectly OK but might cause a problem if the procedure was used in a different problem. - N. J. A. Sloane, Aug 11 2012
  • Mathematica
    palQ[L_] := SameQ[L, Reverse[L]];
    b[L_] := b[L] = Module[{a = palQ[L] // Boole, c}, For[c = 1, c < Length[L], c++, If[palQ[L[[;;c]]], a = a + b[L[[c+1;;]]]]]; a];
    a[n_] := If[n == 1, 1, b[IntegerDigits[n, 2]]];
    a /@ Range[0, 106] (* Jean-François Alcover, Oct 27 2019 *)

A215467 Length of longest palindromic prefix of (n base 2).

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Aug 11 2012

Keywords

Comments

Since the binary expansion of n always begins with a 1, a final 0 can't affect the result, so a(2n) = a(n).

Examples

			...
4 = 100 -> 1
5 = 101 -> 3
6 = 110 -> 2
7 = 111 -> 3
8 = 1000 -> 1
9 = 1001 -> 4
...
		

Crossrefs

Programs

  • Maple
    rev := proc(lis)
        local t1,n,i;
        t1:=[]; n:=nops(lis);
        for i from 1 to n do t1:=[op(t1),lis[n+1-i]]; end do;
        return t1;
    end proc;
    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:
    A215467L := proc(L)
        local a, c;
        a := 1 ;
        for c from 2 to nops(L) do
            if isPal( [op(1..c, L)] ) then
                a := c ;
            end if;
        end do:
        return a;
    end proc:
    A215467 := proc(n)
        if n <= 1 then 1;
        else rev(convert(n, base, 2)) ;
            A215467L(%) ;
        end if;
    end proc:

A050431 Length of longest palindromic subword of (n base 3).

Original entry on oeis.org

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

Views

Author

Keywords

Crossrefs

Programs

  • Maple
    LPS:= proc(L) local nL, n, i;
      nL:= nops(L);
      for n from nL to 1 by -1 do
        for i from 1 to nL-n+1 do
          if L[i..i+n-1] = ListTools:-Reverse(L[i..i+n-1]) then return n fi
      od od:
    end proc:
    seq(LPS(convert(n, base, 3)), n=1..100); # Robert Israel, Dec 17 2020

Formula

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

A050432 Length of longest palindromic subword of (n base 4).

Original entry on oeis.org

1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 2, 3, 1, 1, 2, 3, 2, 2, 1, 3, 2, 1, 1, 3, 1, 2, 2, 1, 3, 1, 1, 2, 3, 1, 2, 2, 3, 2, 1, 1, 3, 2, 2, 1, 1, 3, 1, 2, 1, 3, 1, 1, 2, 3, 2, 2, 2, 3, 3, 4, 2, 2, 3, 3, 3, 3, 3, 1, 2, 1, 3, 1, 1, 2, 2, 3, 2, 2, 3, 4, 3, 3, 2, 3, 2
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Maple
    LPS:= proc(L) local nL,n,i;
      nL:= nops(L);
      for n from nL to 1 by -1 do
        for i from 1 to nL-n+1 do
          if L[i..i+n-1] = ListTools:-Reverse(L[i..i+n-1]) then return n fi
      od od:
    end proc:
    seq(LPS(convert(n,base,4)),n=1..100); # Robert Israel, Dec 17 2020

Formula

a(n) <= min(a(4*n+k): 0 <= k < 4). [Reinhard Zumkeller, Jul 31 2011]

A050433 Length of longest palindromic subword of (n base 5).

Original entry on oeis.org

1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 2, 3, 1, 1, 1, 2, 3, 2, 2, 2, 1, 3, 2, 1, 1, 1, 3, 1, 2, 1, 1, 3, 1, 1, 2, 2, 1, 3, 1, 1, 1, 2, 3, 1, 1, 2, 2, 3, 2, 2, 1, 1, 3, 2, 1, 1, 1, 3, 1, 2, 2, 1, 1, 3, 1, 1, 2, 1, 3, 1, 1, 1, 2, 3, 1, 2
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Maple
    LPS:= proc(L) local nL,n,i;
      nL:= nops(L);
      for n from nL to 1 by -1 do
        for i from 1 to nL-n+1 do
          if L[i..i+n-1] = ListTools:-Reverse(L[i..i+n-1]) then return n fi
      od od:
    end proc:
    seq(LPS(convert(n,base,5)),n=1..100); # Robert Israel, Dec 17 2020

Formula

a(n) <= min(a(5*n+k): 0 <= k < 5). [Reinhard Zumkeller, Jul 31 2011]

A166936 Positive integers n such that when they are written in binary, the longest palindromic substring (or at least one of which that is tied for longest) in binary n begins and ends with a 0.

Original entry on oeis.org

2, 4, 8, 10, 12, 16, 20, 22, 24, 26, 32, 36, 38, 40, 42, 44, 46, 48, 52, 56, 58, 64, 68, 72, 74, 76, 77, 78, 80, 82, 84, 88, 89, 92, 94, 96, 100, 104, 106, 110, 112, 116, 128, 136, 137, 138, 140, 142, 144, 145, 148, 149, 150, 152, 154, 156, 157, 158, 160, 162, 164
Offset: 1

Views

Author

Leroy Quet, Oct 24 2009

Keywords

Crossrefs

Programs

  • Mathematica
    lps0Q[n_]:=Module[{ss=Select[Subsequences[IntegerDigits[n,2]],#==Reverse[#]&],len},len=Max[Length/@ss];AnyTrue[Select[ss,Length[#]==len&],#[[1]]==0&]]; Select[Range[200],lps0Q] (* Harvey P. Dale, Apr 27 2025 *)

Extensions

Extended by Ray Chandler, Mar 11 2010

A166934 A positive integer n is included if the longest palindromic substring (or at least one of which that is tied for longest) in the binary representation of n consists of different valued digits (0 and 1).

Original entry on oeis.org

5, 9, 10, 11, 13, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 29, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 97
Offset: 1

Views

Author

Leroy Quet, Oct 24 2009

Keywords

Comments

All terms of this sequence are contained in sequence A101082. (47 is the first integer that is in A101082, but is not in this sequence.)

Examples

			29 in binary is 11101. There are two substrings in this that are tied for longest palindromic substring, 111 and 101. Since 101 contains both a 0 and 1's, then 29 is in this sequence.
		

Crossrefs

Extensions

Extended by Ray Chandler, Mar 11 2010

A166935 A positive integer n is included if the longest palindromic substring (or at least one of which that is tied for longest) in the binary representation of n consists of identically valued digits (all 0's or all 1's).

Original entry on oeis.org

1, 2, 3, 4, 6, 7, 8, 12, 14, 15, 16, 23, 24, 28, 29, 30, 31, 32, 40, 47, 48, 56, 58, 60, 61, 62, 63, 64, 79, 80, 95, 96, 104, 112, 116, 120, 121, 122, 124, 125, 126, 127, 128, 159, 160, 176, 191, 192, 208, 223, 224, 232, 240, 242, 244, 248, 249, 250, 251, 252, 253, 254
Offset: 1

Views

Author

Leroy Quet, Oct 24 2009

Keywords

Examples

			29 in binary is 11101. There are two substrings in this that are tied for longest palindromic substring, 111 and 101. Since 111 contains only 1's, then 29 is in this sequence.
		

Crossrefs

Extensions

Extended by Ray Chandler, Mar 11 2010

A166937 Positive integers n such that when they are written in binary, the longest palindromic substring (or at least one of which that is tied for longest) in binary n begins and ends with a 1.

Original entry on oeis.org

1, 2, 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, 45, 47, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 65, 66, 67, 68, 69, 70, 71, 73, 75, 77, 79, 81, 83, 84, 85, 86, 87, 89, 90
Offset: 1

Views

Author

Leroy Quet, Oct 24 2009

Keywords

Crossrefs

Extensions

Extended by Ray Chandler, Mar 11 2010

A166938 Those positive integers that are both in sequence A166936 and in sequence A166937.

Original entry on oeis.org

2, 10, 12, 20, 26, 38, 40, 42, 52, 56, 58, 68, 77, 84, 89, 104, 106, 110, 116, 137, 138, 142, 145, 149, 150, 154, 166, 168, 169, 170, 174, 178, 196, 204, 212, 220, 232, 234, 240, 268, 275, 277, 285, 291, 299, 300, 308, 315, 333, 336, 337, 339, 340, 348, 357
Offset: 1

Views

Author

Leroy Quet, Oct 24 2009

Keywords

Comments

Each integer in this sequence, when written in binary, contains at least two palindromic substrings that are tied for the longest such substring, obviously.

Crossrefs

Extensions

Extended by Ray Chandler, Mar 11 2010
Showing 1-10 of 13 results. Next