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-7 of 7 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

A056524 Palindromes with even number of digits.

Original entry on oeis.org

11, 22, 33, 44, 55, 66, 77, 88, 99, 1001, 1111, 1221, 1331, 1441, 1551, 1661, 1771, 1881, 1991, 2002, 2112, 2222, 2332, 2442, 2552, 2662, 2772, 2882, 2992, 3003, 3113, 3223, 3333, 3443, 3553, 3663, 3773, 3883, 3993, 4004, 4114, 4224, 4334, 4444, 4554
Offset: 1

Views

Author

Henry Bottomley, Jun 16 2000

Keywords

Comments

Concatenation of n with reverse of n (keeping leading zeros in the reverse).
A178788(a(n)) = 0 for n > 1. - Reinhard Zumkeller, Jun 30 2010
All of the terms are divisible by eleven. - James Burling, Aug 08 2014

Crossrefs

Cf. A110745 (permutation).

Programs

  • Haskell
    a056524 n = a056524_list !! (n-1)
    a056524_list = [read (ns ++ reverse ns) :: Integer |
                    n <- [0..], let ns = show n]
    -- Reinhard Zumkeller, Dec 28 2011
    
  • Mathematica
    d[n_]:=IntegerDigits[n]; Table[FromDigits[Join[x=d[n],Reverse[x]]],{n,45}] (* Jayanta Basu, May 29 2013 *)
    Select[Flatten[Table[Range[10^n,10^(n+1)-1],{n,1,3,2}]],PalindromeQ] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Feb 22 2018 *)
  • Python
    def a(n): s = str(n); return int(s + s[::-1])
    print([a(n) for n in range(1, 46)]) # Michael S. Branicky, Nov 02 2021

Formula

a(n) = n*10^A055642(n) + A004086(n).
a(n) = 11 * A066492(n).

A076609 Palindromic numbers with prime middle digit.

Original entry on oeis.org

2, 3, 5, 7, 121, 131, 151, 171, 222, 232, 252, 272, 323, 333, 353, 373, 424, 434, 454, 474, 525, 535, 555, 575, 626, 636, 656, 676, 727, 737, 757, 777, 828, 838, 858, 878, 929, 939, 959, 979, 10201, 10301, 10501, 10701, 11211, 11311, 11511, 11711, 12221
Offset: 1

Views

Author

Jani Melik, Oct 21 2002

Keywords

Comments

There are no such with an even number of digits.

Examples

			a(12)=272=2^4*17 is palindromic number and its middle digit 7 is prime, a(13)=323=17*19 is palindromic number and its middle digit 2 is prime, a(14)=333=3^2*37 is palindromic number and its middle digit 3 is prime.
		

Crossrefs

Programs

  • Maple
    ts_numprapal := proc(n) local ad,adr,midigit; ad := convert(n,base,10): adr := ListTools[Reverse](ad): if nops(ad) mod 2 = 0 then return 1; fi; midigit := op( (nops(ad)+1)/2,ad ): if (isprime( midigit )='true' and adr=ad) then return 0; else return 1; fi end: ts_num_pal := proc(i) if ts_numprapal(i) = 0 then return (i) fi end: anumpal := [seq(ts_num_pal(i), i=1..50000)]: anumpal;
  • Mathematica
    pnpmdQ[n_]:=Module[{idn=IntegerDigits[n],len=IntegerLength[n]},OddQ[len] && PalindromeQ[n]&&PrimeQ[idn[[(len+1)/2]]]]; Select[Range[15000],pnpmdQ] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jun 08 2017 *)

A045571 Numbers that are palindromic, divisible by 11 and have an odd number of digits.

Original entry on oeis.org

121, 242, 363, 484, 616, 737, 858, 979, 10901, 11011, 12221, 13431, 14641, 15851, 17171, 18381, 19591, 20702, 21912, 22022, 23232, 24442, 25652, 26862, 28182, 29392, 30503, 31713, 32923, 33033, 34243, 35453, 36663, 37873, 39193, 40304
Offset: 1

Views

Author

Keywords

Comments

All the palindromic numbers with an even number of digits are divisible by 11. The number of palindromic numbers with 2*k+1 digits that are divisible by 11 is (10^(k+1) + (-1)^k)/11, and their asymptotic relative density within the set of all palindromic numbers with an odd number of digits (A056525) is 1/11 (Schmidt, 1988). - Amiram Eldar, Jan 11 2021

Crossrefs

Intersection of A056525 and A083852.

Programs

  • Mathematica
    Select[11 * Range[4000], PalindromeQ[#] && OddQ[IntegerLength[#]] &] (* Amiram Eldar, Jan 11 2021 *)

A056142 Concatenate n, floor[n/10], floor[n/100] ... (but do not continue if floor[.]=0).

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 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, 525, 535, 545, 555
Offset: 0

Views

Author

Henry Bottomley, Jun 15 2000

Keywords

Comments

For 0 < n < 100, a(n) = A056525(n). If n has 3 digits, then a(n) is a palindrome if and only if n is. If n has 4 or 5 digits, then a(n) is a palindrome if and only if all digits of n are equal. - David Wasserman, May 23 2005
Conjecture: if n has 3 or more digits, a(n) is a palindrome only if all the digits of n are the same. It is easy to see that any palindrome can have at most 2 distinct digits: matching digits from the initial n in the concatenation matches each digit after the second with an earlier digit. - Franklin T. Adams-Watters, Sep 07 2006

Crossrefs

Programs

  • Mathematica
    Table[FromDigits[Flatten[IntegerDigits/@DeleteCases[Floor[n/10^Range[ 0,5]],0]]],{n,0,60}] (* Harvey P. Dale, Jul 11 2020 *)

A076612 Palindromic numbers with nonprime middle digit.

Original entry on oeis.org

1, 4, 6, 8, 9, 101, 111, 141, 161, 181, 191, 202, 212, 242, 262, 282, 292, 303, 313, 343, 363, 383, 393, 404, 414, 444, 464, 484, 494, 505, 515, 545, 565, 585, 595, 606, 616, 646, 666, 686, 696, 707, 717, 747, 767, 787, 797, 808, 818, 848, 868, 888, 898, 909
Offset: 1

Views

Author

Jani Melik, Oct 21 2002

Keywords

Comments

By definition, all terms have an odd number of digits. It is not surprising that the sequence of middle digits is 1, 4, 6, 8, 9, 0. - Harvey P. Dale, Jun 15 2024

Crossrefs

Programs

  • Maple
    ts_num_midpal := proc(n) local ad,adr,midigit; ad := convert(n,base,10): adr := ListTools[Reverse](ad): if nops(ad) mod 2 = 0 then return 1; fi; midigit := op( (nops(ad)+1)/2,ad ): if (isprime( midigit )='false' and adr=ad) then return 0; else return 1; fi end: ts_n_pal := proc(n) if ts_num_midpal(n) = 0 then return (i) fi end: anpal := [seq(ts_n_pal(i), i=1..50000)]: anpal;
  • Mathematica
    Select[Range[1000],PalindromeQ[#]&&OddQ[IntegerLength[#]]&&!PrimeQ[IntegerDigits[#][[(IntegerLength[#]+1)/2]]]&] (* Harvey P. Dale, Jun 15 2024 *)
  • Python
    from itertools import chain, count, islice
    def A076612_gen(): # generator of terms
        return chain((1,4,6,8,9),chain.from_iterable((int((s:=str(d))+e+s[::-1]) for d in range(10**l,10**(l+1)) for e in '014689') for l in count(0)))
    A076612_list = list(islice(A076612_gen(),20)) # Chai Wah Wu, Jun 23 2022

A372149 Palindrome numbers consisting only of odd digits.

Original entry on oeis.org

1, 3, 5, 7, 9, 11, 33, 55, 77, 99, 111, 131, 151, 171, 191, 313, 333, 353, 373, 393, 515, 535, 555, 575, 595, 717, 737, 757, 777, 797, 919, 939, 959, 979, 999, 1111, 1331, 1551, 1771, 1991, 3113, 3333, 3553, 3773, 3993, 5115, 5335, 5555, 5775, 5995, 7117, 7337, 7557, 7777, 7997
Offset: 1

Views

Author

James S. DeArmon, Apr 20 2024

Keywords

Crossrefs

Intersection of A002113 and A014261.

Programs

  • Mathematica
    Select[Range[8000], PalindromeQ[#] && Times@@Boole[OddQ[IntegerDigits[#]]] == 1 &] (* Stefano Spezia, Apr 30 2024 *)
  • Python
    from itertools import count, islice, product
    def agen(): # generator of terms
        for d in count(1):
            for p in product("13579", repeat=d//2):
                left = "".join(p)
                for mid in [[""], "13579"][d&1]:
                    yield int(left + mid + left[::-1])
    print(list(islice(agen(), 60))) # Michael S. Branicky, Jun 01 2025

Extensions

Missing 1551 inserted by Stefano Spezia, Apr 30 2024
Showing 1-7 of 7 results.