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

A002113 Palindromes in base 10.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191, 202, 212, 222, 232, 242, 252, 262, 272, 282, 292, 303, 313, 323, 333, 343, 353, 363, 373, 383, 393, 404, 414, 424, 434, 444, 454, 464, 474, 484, 494, 505, 515
Offset: 1

Views

Author

Keywords

Comments

n is a palindrome (i.e., a(k) = n for some k) if and only if n = A004086(n). - Reinhard Zumkeller, Mar 10 2002
It seems that if n*reversal(n) is in the sequence then n = 3 or all digits of n are less than 3. - Farideh Firoozbakht, Nov 02 2014
The position of a palindrome within the sequence can be determined almost without calculation: If the palindrome has an even number of digits, prepend a 1 to the front half of the palindrome's digits. If the number of digits is odd, prepend the value of front digit + 1 to the digits from position 2 ... central digit. Examples: 98766789 = a(19876), 515 = a(61), 8206028 = a(9206), 9230329 = a(10230). - Hugo Pfoertner, Aug 14 2015
This sequence is an additive basis of order at most 49, see Banks link. - Charles R Greathouse IV, Aug 23 2015
The order has been reduced from 49 to 3; see the Cilleruelo-Luca and Cilleruelo-Luca-Baxter links. - Jonathan Sondow, Nov 27 2017
See A262038 for the "next palindrome" and A261423 for the "preceding palindrome" functions. - M. F. Hasler, Sep 09 2015
The number of palindromes with d digits is 10 if d = 1, and otherwise it is 9 * 10^(floor((d - 1)/2)). - N. J. A. Sloane, Dec 06 2015
Sequence A033665 tells how many iterations of the Reverse-then-add function A056964 are needed to reach a palindrome; numbers for which this will never happen are Lychrel numbers (A088753) or rather Kin numbers (A023108). - M. F. Hasler, Apr 13 2019
This sequence is an additive basis of order 3, see Cilleruelo, Luca, & Baxter and Sigg. - Charles R Greathouse IV, Apr 08 2025

References

  • Karl G. Kröber, "Palindrome, Perioden und Chaoten: 66 Streifzüge durch die palindromischen Gefilde" (1997, Deutsch-Taschenbücher; Bd. 99) ISBN 3-8171-1522-9.
  • Clifford A. Pickover, A Passion for Mathematics, Wiley, 2005; see p. 71.
  • Alfred S. Posamentier, Math Charmers, Tantalizing Tidbits for the Mind, Prometheus Books, NY, 2003, pages 50-52.
  • Paulo Ribenboim, The Little Book of Bigger Primes, Springer-Verlag NY 2004. See p. 120.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Subsequence of A061917 and A221221.
A110745 is a subsequence.
Union of A056524 and A056525.
Palindromes in bases 2 through 11: A006995 and A057148, A014190 and A118594, A014192 and A118595, A029952 and A118596, A029953 and A118597, A029954 and A118598, A029803 and A118599, A029955 and A118600, this sequence, A029956. Also A262065 (base 60), A262069 (subsequence).
Palindromic primes: A002385. Palindromic nonprimes: A032350.
Palindromic-pi: A136687.
Cf. A029742 (complement), A086862 (first differences).
Palindromic floor function: A261423, also A261424. Palindromic ceiling: A262038.
Cf. A004086 (read n backwards), A064834, A118031, A136522 (characteristic function), A178788.
Ways to write n as a sum of three palindromes: A261132, A261422.
Minimal number of palindromes that add to n using greedy algorithm: A088601.
Minimal number of palindromes that add to n: A261675.

Programs

  • GAP
    Filtered([0..550],n->ListOfDigits(n)=Reversed(ListOfDigits(n))); # Muniru A Asiru, Mar 08 2019
    
  • Haskell
    a002113 n = a002113_list !! (n-1)
      a002113_list = filter ((== 1) . a136522) [1..] -- Reinhard Zumkeller, Oct 09 2011
    
  • Haskell
    import Data.List.Ordered (union)
      a002113_list = union a056524_list a056525_list -- Reinhard Zumkeller, Jul 29 2015, Dec 28 2011
    
  • Magma
    [n: n in [0..600] | Intseq(n, 10) eq Reverse(Intseq(n, 10))]; // Vincenzo Librandi, Nov 03 2014
    
  • Maple
    read transforms; t0:=[]; for n from 0 to 2000 do if digrev(n) = n then t0:=[op(t0),n]; fi; od: t0;
    # Alternatively, to get all palindromes with <= N digits in the list "Res":
    N:=5;
    Res:= $0..9:
    for d from 2 to N do
      if d::even then
        m:= d/2;
        Res:= Res, seq(n*10^m + digrev(n),n=10^(m-1)..10^m-1);
      else
        m:= (d-1)/2;
        Res:= Res, seq(seq(n*10^(m+1)+y*10^m+digrev(n),y=0..9),n=10^(m-1)..10^m-1);
      fi
    od: Res:=[Res]: # Robert Israel, Aug 10 2014
    # A variant: Gets all base-10 palindromes with exactly d digits, in the list "Res"
    d:=4:
    if d=1 then Res:= [$0..9]:
    elif d::even then
        m:= d/2:
        Res:= [seq(n*10^m + digrev(n), n=10^(m-1)..10^m-1)]:
    else
        m:= (d-1)/2:
        Res:= [seq(seq(n*10^(m+1)+y*10^m+digrev(n), y=0..9), n=10^(m-1)..10^m-1)]:
    fi:
    Res; # N. J. A. Sloane, Oct 18 2015
    isA002113 := proc(n)
        simplify(digrev(n) = n) ;
    end proc: # R. J. Mathar, Sep 09 2015
  • Mathematica
    palQ[n_Integer, base_Integer] := Module[{idn = IntegerDigits[n, base]}, idn == Reverse[idn]]; (* then to generate any base-b sequence for 1 < b < 37, replace the 10 in the following instruction with b: *) Select[Range[0, 1000], palQ[#, 10] &]
    base10Pals = {0}; r = 2; Do[Do[AppendTo[base10Pals, n * 10^(IntegerLength[n] - 1) + FromDigits@Rest@Reverse@IntegerDigits[n]], {n, 10^(e - 1), 10^e - 1}]; Do[AppendTo[base10Pals, n * 10^IntegerLength[n] + FromDigits@Reverse@IntegerDigits[n]], {n, 10^(e - 1), 10^e - 1}], {e, r}]; base10Pals (* Arkadiusz Wesolowski, May 04 2012 *)
    nthPalindromeBase[n_, b_] := Block[{q = n + 1 - b^Floor[Log[b, n + 1 - b^Floor[Log[b, n/b]]]], c = Sum[Floor[Floor[n/((b + 1) b^(k - 1) - 1)]/(Floor[n/((b + 1) b^(k - 1) - 1)] - 1/b)] - Floor[Floor[n/(2 b^k - 1)]/(Floor[n/(2 b^k - 1)] - 1/ b)], {k, Floor[Log[b, n]]}]}, Mod[q, b] (b + 1)^c * b^Floor[Log[b, q]] + Sum[Floor[Mod[q, b^(k + 1)]/b^k] b^(Floor[Log[b, q]] - k) (b^(2 k + c) + 1), {k, Floor[Log[b, q]]}]] (* after the work of Eric A. Schmidt, works for all integer bases b > 2 *)
    Array[nthPalindromeBase[#, 10] &, 61, 0] (* please note that Schmidt uses a different, a more natural and intuitive offset, that of a(1) = 1. - Robert G. Wilson v, Sep 22 2014 and modified Nov 28 2014 *)
    Select[Range[10^3], PalindromeQ] (* Michael De Vlieger, Nov 27 2017 *)
    nLP[cn_Integer]:=Module[{s,len,half,left,pal,fdpal},s=IntegerDigits[cn]; len=Length[s]; half=Ceiling[len/2]; left=Take[s,half]; pal=Join[left,Reverse[ Take[left,Floor[len/2]]]]; fdpal=FromDigits[pal]; Which[cn==9,11,fdpal>cn,fdpal,True,left=IntegerDigits[ FromDigits[left]+1]; pal=Join[left,Reverse[Take[left,Floor[len/2]]]]; FromDigits[pal]]]; NestList[nLP,0,100] (* Harvey P. Dale, Dec 10 2024 *)
  • PARI
    is_A002113(n)=Vecrev(n=digits(n))==n \\ M. F. Hasler, Nov 17 2008, updated Apr 26 2014, Jun 19 2018
    
  • PARI
    is(n)=n=digits(n);for(i=1,#n\2,if(n[i]!=n[#n+1-i],return(0))); 1 \\ Charles R Greathouse IV, Jan 04 2013
    
  • PARI
    a(n)={my(d,i,r);r=vector(#digits(n-10^(#digits(n\11)))+#digits(n\11));n=n-10^(#digits(n\11));d=digits(n);for(i=1,#d,r[i]=d[i];r[#r+1-i]=d[i]);sum(i=1,#r,10^(#r-i)*r[i])} \\ David A. Corneth, Jun 06 2014
    
  • PARI
    \\ recursive--feed an element a(n) and it gives a(n+1)
    nxt(n)=my(d=digits(n));i=(#d+1)\2;while(i&&d[i]==9,d[i]=0;d[#d+1-i]=0;i--);if(i,d[i]++;d[#d+1-i]=d[i],d=vector(#d+1);d[1]=d[#d]=1);sum(i=1,#d,10^(#d-i)*d[i]) \\ David A. Corneth, Jun 06 2014
    
  • PARI
    \\ feed a(n), returns n.
    inv(n)={my(d=digits(n));q=ceil(#d/2);sum(i=1,q,10^(q-i)*d[i])+10^floor(#d/2)} \\ David A. Corneth, Jun 18 2014
    
  • PARI
    inv_A002113(P)={P\(P=10^(logint(P+!P,10)\/2))+P} \\ index n of palindrome P = a(n), much faster than above: no sum is needed. - M. F. Hasler, Sep 09 2018
    
  • PARI
    A002113(n,L=logint(n,10))=(n-=L=10^max(L-(n<11*10^(L-1)),0))*L+fromdigits(Vecrev(digits(if(nM. F. Hasler, Sep 11 2018
    
  • Python
    # edited by M. F. Hasler, Jun 19 2018
    def A002113_list(nMax):
      mlist=[]
      for n in range(nMax+1):
         mstr=str(n)
         if mstr==mstr[::-1]:
            mlist.append(n)
      return mlist # Bill McEachen, Dec 17 2010
    
  • Python
    from itertools import chain
    A002113 = sorted(chain(map(lambda x:int(str(x)+str(x)[::-1]),range(1,10**3)),map(lambda x:int(str(x)+str(x)[-2::-1]), range(10**3)))) # Chai Wah Wu, Aug 09 2014
    
  • Python
    from itertools import chain, count
    A002113 = chain(k for k in count(0) if str(k) == str(k)[::-1])
    print([next(A002113) for k in range(60)]) # Jan P. Hartkopf, Apr 10 2021
    
  • Python
    is_A002113 = lambda n: (s:=str(n))[::-1]==s # M. F. Hasler, May 23 2024
    
  • Python
    from math import log10, floor
    def A002113(n):
      if n < 2: return 0
      P = 10**floor(log10(n//2)); M = 11*P
      s = str(n - (P if n < M else M-P))
      return int(s + s[-2 if n < M else -1::-1]) # M. F. Hasler, Jun 06 2024
    
  • SageMath
    [n for n in (0..515) if Word(n.digits()).is_palindrome()] # Peter Luschny, Sep 13 2018
    
  • Scala
    def palQ(n: Int, b: Int = 10): Boolean = n - Integer.parseInt(n.toString.reverse) == 0
    (0 to 999).filter(palQ()) // _Alonso del Arte, Nov 10 2019

Formula

A136522(a(n)) = 1.
A178788(a(n)) = 0 for n > 9. - Reinhard Zumkeller, Jun 30 2010
A064834(a(n)) = 0. - Reinhard Zumkeller, Sep 18 2013
a(n+1) = A262038(a(n)+1). - M. F. Hasler, Sep 09 2015
Sum_{n>=2} 1/a(n) = A118031. - Amiram Eldar, Oct 17 2020
a(n) = (floor(d(n)/(c(n)*9 + 1)))*10^A055642(d(n)) + A004086(d(n)) where b(n, k) = ceiling(log((n + 1)/k)/log(10)), c(n) = b(n, 2) - b(n, 11) and d(n) = (n - A086573(b(n*(2 - c(n)), 2) - 1)/2 - 1). - Alan Michael Gómez Calderón, Mar 11 2025

A261675 Minimal number of palindromes in base 10 that add to n.

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, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 2, 1, 2, 2, 2, 2
Offset: 0

Views

Author

N. J. A. Sloane, Sep 02 2015

Keywords

Comments

This sequence coincides with A088601 for n <= 301, but differs at n=302.
Although A088601 and this sequence agree for a large number of terms, because of their importance they warrant separate entries.
Cilleruelo and Luca prove that a(n) <= 3 (in fact they prove this for any fixed base g>=5). - Danny Rorabaugh, Feb 26 2016

Crossrefs

Programs

  • PARI
    ispal(n)=my(d=digits(n)); d==Vecrev(d);
    a(n)=my(L=n\2,d,e); if(ispal(n), return(1)); d=[1]; while((e=fromdigits(d))<=L, if(ispal(n-e), return(2)); my(k=#d,i=(k+1)\2); while(i&&d[i]==9, d[i]=0; d[k+1-i]=0; i--); if(i, d[i]++; d[k+1-i]=d[i], d=vector(#d+1); d[1]=d[#d]=1)); 3; \\ Charles R Greathouse IV, Nov 12 2018

A213879 Positive palindromes that are not the sum of two positive palindromes.

Original entry on oeis.org

1, 111, 131, 141, 151, 161, 171, 181, 191, 1331, 1441, 1551, 1661, 1771, 1881, 1991, 10301, 10401, 10501, 10601, 10701, 10801, 10901, 11111, 11211, 11311, 11411, 11511, 11611, 11711, 11811, 11911, 12021, 12121, 12321, 12421, 12521, 12621, 12721, 12821
Offset: 1

Views

Author

Arkadiusz Wesolowski, Jun 23 2012

Keywords

Comments

These numbers do not occur in A035137.

Examples

			22 is not a member because 22 = 11 + 11.
		

Crossrefs

Programs

  • Maple
    # From N. J. A. Sloane, Sep 09 2015: bP is a list of the palindromes
    a:={}; M:=400; for n from 3 to M do p:=bP[n];
    # is p a sum of two palindromes?
    sw:=-1; for i from 2 to n-1 do j:=p-bP[i]; if digrev(j)=j then sw:=1; break; fi;
    od;
    if sw<0 then a:={op(a),p}; fi; od:
    b:=sort(convert(a,list));
  • Mathematica
    lst1 = {}; lst2 = {}; r = 12821; Do[If[FromDigits@Reverse@IntegerDigits[n] == n, AppendTo[lst1, n]], {n, r}]; l = Length[lst1]; Do[s = lst1[[i]] + lst1[[j]]; AppendTo[lst2, s], {i, l - 1}, {j, i}]; Complement[lst1, lst2]
    palQ[n_] := Reverse[x = IntegerDigits[n]] == x; t1 = Select[Range[12900], palQ[#] &]; Complement[t1, Union[Flatten[Table[i + j, {i, t1}, {j, t1}]]]] (* Jayanta Basu, Jun 15 2013 *)

Formula

({ A002113 } intersect { A319477 }) minus { 0 }. - Alois P. Heinz, Sep 19 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

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

A261677 Numbers whose representation as a sum of palindromes using the greedy algorithm requires more than are needed using the optimal algorithm.

Original entry on oeis.org

302, 403, 504, 605, 706, 807, 908, 1011, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1032, 1033, 1035, 1036, 1037, 1038, 1039, 1040, 1043, 1044, 1046, 1047, 1048, 1049, 1050, 1054, 1055, 1057, 1058
Offset: 1

Views

Author

N. J. A. Sloane, Sep 02 2015

Keywords

Comments

Numbers n such that A088601(n) > A261675(n).

Crossrefs

A262528 Maximum number of backward steps k needed to find a representation of an n-digit decimal number x as a sum of three base-10 palindromes of the form k-th largest base-10 palindrome <= x plus a number representable as sum of two base-10 palindromes from A260255.

Original entry on oeis.org

0, 1, 1, 3, 3, 11, 4, 10, 4, 23, 9, 15, 6, 23, 11
Offset: 1

Views

Author

Hugo Pfoertner, Sep 26 2015

Keywords

Comments

The sequence terms are counterexamples to the second part of the claim stated in the answers to the Math Magic Problem of the Month (June 1999) that "all sufficiently large numbers seem to be the sum of 3 palindromes, one of which is the biggest or second biggest possible", which would mean all a(k)=2 for k "sufficiently large".
Since exhaustive search is currently (2015) considered as not feasible, a(16)>=16, a(17)>=7, a(18)>=25, a(19)>=14 are only lower bounds for the next sequence terms.
M. Sigg has shown that a(n)>=3 for n = 5 + 4 * j.

Examples

			a(1)=0 because all 1-digit numbers are palindromes,
a(2)=a(3)=1 because all 2-digit and all 3-digit numbers can be represented by the nearest smaller palindrome and a number <=10, e.g., 201=191+9+1.
a(4)=3, because for the number 2023 the largest palindrome leading to a difference representable as sum of two palindromes is 1881. 2023-2002=21 and 2023-1991=32 are not in A260255. 2023-1881=142=141+1 is in A260255. No other 4-digit number requires more than 3 backward steps.
a(6)=11 because for the 6-digit number 101199 none of the first 10 differences 101199-101101=98, 101199-10001=1198, 101199-99999=1200, 101199-99899=1300, 101199-99799=1400, 101199-99699=1500, 101199-99599=1600, 101199-99499=1700, 101199-99399=1800, 101199-99299=1900 is representable as sum of two palindromes (i.e., are in A035137), whereas the 11th palindrome 99199 leads to 101199-99199=2000=1991+9.
a(18)>=25 because for the number x=100000001814566071 only the 25th palindrome < x 99999997779999999 produces the first difference 4034566072 representable as sum of 2 palindromes.
		

Crossrefs

A261676 Numbers which when represented as a sum of palindromes using the greedy algorithm require more than 3 palindromes.

Original entry on oeis.org

1022, 1033, 1044, 1055, 1066, 1077, 1088, 1099, 1132, 1143, 1154, 1165, 1176, 1187, 1198, 1209, 1242, 1253, 1264, 1275, 1286, 1297, 1308, 1319, 1352, 1363, 1374, 1385, 1396, 1407, 1418, 1429, 1462, 1473, 1484, 1495, 1506, 1517, 1528, 1539, 1572, 1583, 1594
Offset: 1

Views

Author

N. J. A. Sloane, Sep 02 2015

Keywords

Comments

Numbers n such that A088601(n) > 3.

Crossrefs

Showing 1-8 of 8 results.