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.

Previous Showing 11-20 of 86 results. Next

A136687 Number of palindromes in the range [0,n] inclusive.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Apr 21 2008

Keywords

Comments

Partial sums of A136522. [Typo fixed by Colin Barker, Apr 26 2015]

Crossrefs

Programs

  • Mathematica
    palQ[n_]:=Module[{idn=IntegerDigits[n]},idn==Reverse[idn]]; Accumulate[ Table[ If[palQ[n],1,0],{n,0,80}]] (* Harvey P. Dale, May 11 2014 *)
  • PARI
    A136687(n)=inv_A002113(A261423(n)) \\ M. F. Hasler, Sep 09 2018
    
  • Python
    def A136687(n):
        l = len(s:=str(n))
        k = l+1>>1
        return n//10**(l-k)-(int(s[k-1::-1])>n%10**k)+10**(k-1+(l&1^1)) # Chai Wah Wu, Jul 24 2024

Formula

a(n) = inv_A002113(A261423(n)), where inv_A002113 is the inverse of A002113, i.e., it yields the index of a palindrome. - M. F. Hasler, Sep 10 2018

A261913 The palindromic order of n (defined in Comments).

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Sep 10 2015

Keywords

Comments

Order 1: palindromes (A002113);
Order 2: not order 1 but is the sum of two palindromes (A261907);
Order 3: not order 1 or 2, but n - previous_palindrome(n) (i.e., n - A261914(n)) gives a number of order 2 (A261910);
Order 4: not order 1, 2, or 3, but subtracting previous_palindrome(previous_palindrome(n)) gives a number of order 2 (A261911);
Order 5: not orders 1, 2, 3, or 4 (A261912).

Crossrefs

Closely related to A261675. See also A088601.

Formula

a(n) = A088601(n). - R. J. Mathar, Feb 14 2023

A262037 Replace the second half of digits of n with the first half in reverse order.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 77, 77, 77, 77, 77, 77, 77
Offset: 0

Views

Author

M. F. Hasler, Sep 08 2015

Keywords

Comments

This is related to the "palindromic floor" and "palindromic ceiling" functions A261423 and A262038: a(n) = A261423(n) iff the first half of digits reversed does not exceed the second half of digits (without considering the middle digit in case of an odd number of digits), and a(n) = A262038(n) in the opposite case, i.e., first half of digits reversed is greater than or equal to second half of digits.
a(n) is either equal to the palindromic floor A261423(n) (e.g., a(1234) = 1221), or to the palindromic ceiling A262038(n) (= next larger palindrome, e.g., a(1324)=1331). In this sense it can be seen as a "palindromic round" function. However, it does not always yield the closest of the two (a(1900) = 1991 but 1881 would be closer to 1900). The sequence A262040 which has this property would better merit the name of "palindromic round function".
This simple function can be used to construct the next larger or next smaller palindrome, A261423 and A262038: indeed, if a(n) has the required property (less than or greater than n) then it is already the desired result, otherwise the result is given by a(n +- 10^k), where k is half the number of digits of n.

Examples

			a(31) = 33 since the second half ("1") gets replaced by the first half ("3").
a(314) = 313 since the second half ("4") is replaced by the first half ("3"), the middle "1" being untouched.
a(3141) = 3113 since the second half (41) is replaced by the first half (31), reversed (13).
a(31415) = 31413 as above, the middle 4 being left untouched.
a(314156) = 314413. This is the first instance in these examples where a(n) differs from A261423(n), which would yield 313313 here.
		

Crossrefs

Programs

  • Mathematica
    f[n_] := Block[{d = IntegerDigits@ n}, FromDigits[Take[d, Ceiling[Length[d]/2]]~Join~Reverse@ Take[d, Floor[Length[d]/2]]]]; Table[f@ n, {n, 0, 120}] (* Michael De Vlieger, Sep 09 2015 *)
  • PARI
    a(n,d=digits(n),m=sum(k=1,#d\2,d[k]*10^(k-1)))=n+m-n%10^(#d\2)
    
  • Python
    def A262037(n):
        s = str(n); h = s[:(len(s)+1)//2]; return int(h + h[-1-len(s)%2::-1])
    print([A262037(n) for n in range(77)]) # Michael S. Branicky, Sep 15 2022

A109326 Smallest positive number that requires n steps to be represented as a sum of palindromes using the greedy algorithm.

Original entry on oeis.org

1, 10, 21, 1022, 101023, 1000101024
Offset: 1

Views

Author

David Wasserman, Aug 11 2005

Keywords

Comments

Index of first occurrence of n in A088601.
Presumably this sequence is unbounded. - N. J. A. Sloane, Aug 28 2015
The greedy algorithm means iteration of A261424 until a palindrome is reached. For n = 3, 4, ... we have a(n+1) = 10^L(n) + a(n) + 1 with L(n) = 2^(n-2) + 1 = length(a(n))*2 - 3 for n > 3. We have a(7) <= 10^17 + 1000101025, a(8) <= 10^33 + 10^17 + 1000101026, a(9) <= 10^65 + 10^33 + 10^17 + 1000101027, a(10) <= 10^129 + 10^65 + 10^33 + 10^17 + 1000101028, etc, with conjectured equality. - M. F. Hasler, Sep 08 2015, edited Sep 09 2018

Crossrefs

Programs

  • Python
    # uses functions in A088601
    def afind(limit):
        record = 0
        for i in range(1, limit+1):
            steps = A088601(i)
            if steps > record: print(i, end=", "); record = steps
    afind(10**6) # Michael S. Branicky, Jul 12 2021

Formula

a(n) = Sum_{0 <= k <= n-3} 10^(2^k+1) + n - 82, for n > 2 (conjectured). - M. F. Hasler, Sep 08 2015

Extensions

Edited by N. J. A. Sloane, Aug 28 2015

A261914 Largest palindrome < n (or 0 if n=0).

Original entry on oeis.org

0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55
Offset: 0

Views

Author

N. J. A. Sloane, Sep 10 2015

Keywords

Crossrefs

Similar to but of course different from A261423.

Programs

  • Haskell
    a261914 n = a261914_list !! n
    a261914_list = f 0 a002113_list where
       f n ps@(p:ps'@(p':_)) = p : f (n + 1) (if n < p' then ps else ps')
    -- Reinhard Zumkeller, Sep 16 2015
  • Maple
    # Pal has list of palindromes; palfloor is A261423
    palfloor:=proc(n) global Pal; local i;
    for i from 1 to nops(Pal) do
       if Pal[i]=n then return(n); fi;
       if Pal[i]>n then return(Pal[i-1]); fi;
    od:
    end;
    prevpal:=proc(n) global palfloor;
    if n=0 then return(0);
    elif member(n,Pal) then return(palfloor(n-1));
    else return(palfloor(n)); fi; end;
  • Mathematica
    lp[n_]:=Module[{k=n-1},While[!PalindromeQ[k],k--];k]; Join[{0},Array[lp,70]] (* Harvey P. Dale, Oct 17 2022 *)

Formula

a(n) = A261423(n-1) for all n>0. - M. F. Hasler, Sep 11 2015

A180458 Largest palindromic number <= n-th-prime.

Original entry on oeis.org

2, 3, 5, 7, 11, 11, 11, 11, 22, 22, 22, 33, 33, 33, 44, 44, 55, 55, 66, 66, 66, 77, 77, 88, 88, 101, 101, 101, 101, 111, 121, 131, 131, 131, 141, 151, 151, 161, 161, 171, 171, 181, 191, 191, 191, 191, 202, 222, 222, 222, 232, 232, 232, 242, 252, 262, 262, 262, 272
Offset: 1

Views

Author

Giovanni Teofilatto, Sep 06 2010

Keywords

Crossrefs

Programs

  • Maple
    # given lists Primes of primes and Palis of palindromes, with Palis[-1] > Primes[-1]
    m:= 1; A:= 'A':
    for n from 1 to nops(Primes) do
      while m < nops(Palis) and Palis[m+1] <= Primes[n] do m:= m+1 od:
      A[n]:= Palis[m]
    od:
    seq(A[i],i=1..nops(Primes)); # Robert Israel, Apr 26 2016
  • Mathematica
    lpn[n_]:=Module[{k=0},While[!PalindromeQ[n-k],k++];n-k]; Table[lpn[n],{n,Prime[Range[60]]}] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Dec 18 2020 *)

Extensions

Corrected by Robert Israel, Apr 26 2016

A262039 Nearest palindrome to n; in case of a tie choose the larger palindrome.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 11, 11, 11, 11, 11, 11, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 77, 77
Offset: 0

Views

Author

M. F. Hasler, Sep 08 2015

Keywords

Comments

In analogy to the numerical "round" function, we "round up" to the next larger palindrome A262038(n) if it is at the same distance or closer, else we "round down" to the next smaller palindrome A261423(n). See A262040 for a variant where the next smaller palindrome is chosen in case of equal distance.

Examples

			a(10) = 11 since we round up if the next smaller palindrome (here 9) is at the same distance, both 9 and 11 are here at distance 1 from n = 10.
a(16) = 11 since |16 - 11| = 5 is smaller than |16 - 22| = 6.
a(17) = 22 since |17 - 22| = 5 is smaller than |17 - 11| = 6.
a(27) = 22 since |22 - 27| = 5 is smaller than |27 - 33| = 6.
a(28) = 33 since |33 - 28| = 5 is smaller than |22 - 28| = 6, and so on.
a(100) = 101 because we round up again in this case, where 99 and 101 both are at distance 1 from n = 100.
		

Crossrefs

Programs

  • Mathematica
    palQ[n_] := Block[{d = IntegerDigits@ n}, d == Reverse@ d];
    f[n_] := Block[{k = n}, While[Nand[palQ@ k, k > -1], k--]; k];
    g[n_] := Block[{k = n}, While[! palQ@ k, k++]; k];
    h[n_] := Block[{a = f@ n, b = g@ n}, Which[palQ@ n, n, (b - n) - (n - a) > 0, a, (b - n) - (n - a) <= 0, b]]; Table[h@ n, {n, 0, 73}] (* Michael De Vlieger, Sep 09 2015 *)

A262040 Nearest palindrome to n; in case of a tie choose the smaller palindrome.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 11, 11, 11, 11, 11, 11, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 77, 77
Offset: 0

Views

Author

M. F. Hasler, Sep 08 2015

Keywords

Comments

In contrast to A262039, here we "round down" to the next smaller palindrome A261423(n) if it is at the same distance or closer, else we "round up" to the next larger palindrome A262038(n).

Examples

			a(10) = 9 since we round down if the next larger palindrome (here 11) is at the same distance, both 9 and 11 are here at distance 1 from n = 10.
a(16) = 11 since |16 - 11| = 5 is smaller than |16 - 22| = 6.
a(17) = 22 since |17 - 22| = 5 is smaller than |17 - 11| = 6.
a(27) = 22 since |22 - 27| = 5 is smaller than |27 - 33| = 6.
a(28) = 33 since |33 - 28| = 5 is smaller than |22 - 28| = 6, and so on.
a(100) = 99 because we round down in this case, where 99 and 101 both are at distance 1 from n = 100.
		

Crossrefs

Programs

  • Mathematica
    palQ[n_] := Block[{d = IntegerDigits@ n}, d == Reverse@ d];
    f[n_] := Block[{k = n}, While[Nand[palQ@ k, k > -1], k--]; k];
    g[n_] := Block[{k = n}, While[! palQ@ k, k++]; k];
    h[n_] := Block[{a = f@ n, b = g@ n}, Which[palQ@ n, n, (b - n) - (n - a) >= 0, a, (b - n) - (n - a) < 0, b]]; Table[h@ n, {n, 0, 73}] (* Michael De Vlieger, Sep 09 2015 *)

A262087 Largest palindrome p such that n-p is again a palindrome, or 0 if no such p exists.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 0, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 0, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 0, 77, 77, 77, 77, 77, 77
Offset: 0

Views

Author

M. F. Hasler, Sep 10 2015

Keywords

Crossrefs

Programs

Formula

a(n) = 0 for n in {0} union A035137.

A262257 Minimal number of editing steps (delete, insert or substitute) to transform n in decimal representation into the largest palindrome <= n.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 0, 1, 1, 2, 2, 2, 2, 2, 2
Offset: 0

Views

Author

Reinhard Zumkeller, Sep 16 2015

Keywords

Comments

a(n) = Levenshtein distance between n and A261423(n);
0 <= a(n) <= A055642(n);
a(A002113(n)) = 0; a(m) = 0 iff A136522(m) = 1.

Examples

			.     n | A261423(n) | a(n)          n | A261423(n) | a(n)
.  -----+------------+-----      ------+------------+-------
.   100 |         99 |    3       1000 |        999 |    4
.   101 |        101 |    0       1001 |       1001 |    0
.   102 |        101 |    1       1002 |       1001 |    1
.   103 |        101 |    1       1003 |       1001 |    1
.   104 |        101 |    1       1004 |       1001 |    1
.   105 |        101 |    1       1005 |       1001 |    1
.   106 |        101 |    1       1006 |       1001 |    1
.   107 |        101 |    1       1007 |       1001 |    1
.   108 |        101 |    1       1008 |       1001 |    1
.   109 |        101 |    1       1009 |       1001 |    1
.   110 |        101 |    2       1010 |       1001 |    2
.   111 |        111 |    0       1011 |       1001 |    1
.   112 |        111 |    1       1012 |       1001 |    2
.   113 |        111 |    1       1013 |       1001 |    2
.   114 |        111 |    1       1014 |       1001 |    2
.   115 |        111 |    1       1015 |       1001 |    2
.   116 |        111 |    1       1016 |       1001 |    2
.   117 |        111 |    1       1017 |       1001 |    2
.   118 |        111 |    1       1018 |       1001 |    2
.   119 |        111 |    1       1019 |       1001 |    2
.   120 |        111 |    2       1020 |       1001 |    2
.   121 |        121 |    0       1021 |       1001 |    1
.   122 |        121 |    1       1022 |       1001 |    2
.   123 |        121 |    1       1023 |       1001 |    2
.   124 |        121 |    1       1024 |       1001 |    2
.   125 |        121 |    1       1025 |       1001 |    2 .
		

Crossrefs

Programs

  • Haskell
    import Data.Function (on); import Data.List (genericIndex)
    a262257 n = genericIndex a262257_list n
    a262257_list = zipWith (levenshtein `on` show) [0..] a261423_list where
       levenshtein us vs = last $ foldl transform [0..length us] vs where
         transform xs@(x:xs') c = scanl compute (x+1) (zip3 us xs xs') where
           compute z (c', x, y) = minimum [y+1, z+1, x + fromEnum (c' /= c)]
Previous Showing 11-20 of 86 results. Next