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 55 results. Next

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

A002385 Palindromic primes: prime numbers whose decimal expansion is a palindrome.

Original entry on oeis.org

2, 3, 5, 7, 11, 101, 131, 151, 181, 191, 313, 353, 373, 383, 727, 757, 787, 797, 919, 929, 10301, 10501, 10601, 11311, 11411, 12421, 12721, 12821, 13331, 13831, 13931, 14341, 14741, 15451, 15551, 16061, 16361, 16561, 16661, 17471, 17971, 18181, 18481, 19391, 19891, 19991
Offset: 1

Views

Author

Keywords

Comments

Every palindrome with an even number of digits is divisible by 11, so 11 is the only member of the sequence with an even number of digits. - David Wasserman, Sep 09 2004
This holds in any number base A006093(n), n>1. - Lekraj Beedassy, Mar 07 2005 and Dec 06 2009
The log-log plot shows the fairly regular structure of these numbers. - T. D. Noe, Jul 09 2013
Conjecture: The only primes with palindromic prime indices that are palindromic primes themselves are 3, 5 and 11. Tested for the primes with the first 8000000 palindromic prime indices. - Ivan N. Ianakiev, Oct 10 2014
It follows from the above conjecture that 2 is the only k such that k, prime(k), prime(m) = k + prime(k) and m are all palindromic primes. - Ivan N. Ianakiev, Mar 17 2025
Banks, Hart, and Sakata derive a nontrivial upper bound for the number of prime palindromes n <= x as x -> oo. It follows that almost all palindromes are composite. The results hold in any base. The authors use Weil's bound for Kloosterman sums. - Jonathan Sondow, Jan 02 2018
Number of terms < 100^k, k >= 1: 5, 20, 113, 781, 5953, 47995, 401698, .... - Robert G. Wilson v, Jan 03 2018, corrected by M. F. Hasler, Dec 19 2024
Initially the above comment listed 4, 20, 113, ... which is the number of terms less than 10, 1000, 10^5, ..., i.e., up to 10^(2k-1), k >= 1. The number of terms < 10^k are the cumulative sums of A016115(n) (number of prime palindromes with n digits) up to n = k. - M. F. Hasler, Dec 19 2024

References

  • A. H. Beiler, Recreations in the Theory of Numbers, Dover, NY, 1964, p. 228.
  • Paulo Ribenboim, The Little Book of Bigger Primes, Springer-Verlag NY 2004. See pp. 120-121.
  • 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

A007500 = this sequence union A006567.
Subsequence of A188650; A188649(a(n)) = a(n); see A033620 for multiplicative closure. [Reinhard Zumkeller, Apr 11 2011]
Cf. A016041, A029732, A069469, A117697, A046942, A032350 (Palindromic nonprime numbers).
Cf. A016115 (number of prime palindromes with n digits).

Programs

  • GAP
    Filtered([1..20000],n->IsPrime(n) and ListOfDigits(n)=Reversed(ListOfDigits(n))); # Muniru A Asiru, Mar 08 2019
  • Haskell
    a002385 n = a002385_list !! (n-1)
    a002385_list = filter ((== 1) . a136522) a000040_list
    -- Reinhard Zumkeller, Apr 11 2011
    
  • Maple
    ff := proc(n) local i,j,k,s,aa,nn,bb,flag; s := n; aa := convert(s,string); nn := length(aa); bb := ``; for i from nn by -1 to 1 do bb := cat(bb,substring(aa,i..i)); od; flag := 0; for j from 1 to nn do if substring(aa,j..j)<>substring(bb,j..j) then flag := 1 fi; od; RETURN(flag); end; gg := proc(i) if ff(ithprime(i)) = 0 then RETURN(ithprime(i)) fi end;
    rev:=proc(n) local nn, nnn: nn:=convert(n,base,10): add(nn[nops(nn)+1-j]*10^(j-1),j=1..nops(nn)) end: a:=proc(n) if n=rev(n) and isprime(n)=true then n else fi end: seq(a(n),n=1..20000); # rev is a Maple program to revert a number - Emeric Deutsch, Mar 25 2007
    # A002385 Gets all base-10 palindromic primes with exactly d digits, in the list "Res"
    d:=7; # (say)
    if d=1 then Res:= [2,3,5,7]:
    elif d=2 then Res:= [11]:
    elif d::even then
        Res:=[]:
    else
        m:= (d-1)/2:
        Res2 := [seq(seq(n*10^(m+1)+y*10^m+digrev(n), y=0..9), n=10^(m-1)..10^m-1)]:
        Res:=[]: for x in Res2 do if isprime(x) then Res:=[op(Res),x]; fi: od:
    fi:
    Res; # N. J. A. Sloane, Oct 18 2015
  • Mathematica
    Select[ Prime[ Range[2100] ], IntegerDigits[#] == Reverse[ IntegerDigits[#] ] & ]
    lst = {}; e = 3; Do[p = n*10^(IntegerLength[n] - 1) + FromDigits@Rest@Reverse@IntegerDigits[n]; If[PrimeQ[p], AppendTo[lst, p]], {n, 10^e - 1}]; Insert[lst, 11, 5] (* Arkadiusz Wesolowski, May 04 2012 *)
    Join[{2,3,5,7,11},Flatten[Table[Select[Prime[Range[PrimePi[ 10^(2n)]+1, PrimePi[ 10^(2n+1)]]],# == IntegerReverse[#]&],{n,3}]]] (* The program uses the IntegerReverse function from Mathematica version 10 *) (* Harvey P. Dale, Apr 22 2016 *)
    genPal[n_Integer, base_Integer: 10] := Block[{id = IntegerDigits[n, base], insert = Join[{{}}, {# - 1} & /@ Range[base]]}, FromDigits[#, base] & /@ (Join[id, #, Reverse@id] & /@ insert)]; k = 1; lst = {2, 3, 5, 7}; While[k < 19, p = Select[genPal[k], PrimeQ];
    If[p != {}, AppendTo[lst, p]]; k++]; Flatten@ lst (* RGWv *)
    Select[ Prime[ Range[2100]], PalindromeQ] (* Jean-François Alcover, Feb 17 2018 *)
    NestList[NestWhile[NextPrime, #, ! PalindromeQ[#2] &, 2] &, 2, 41] (* Jan Mangaldan, Jul 01 2020 *)
  • PARI
    is(n)=n==eval(concat(Vecrev(Str(n))))&&isprime(n) \\ Charles R Greathouse IV, Nov 20 2012
    
  • PARI
    forprime(p=2,10^5, my(d=digits(p,10)); if(d==Vecrev(d),print1(p,", "))); \\ Joerg Arndt, Aug 17 2014
    
  • PARI
    A002385_row(n)=select(is_A002113, primes([10^(n-1),10^n])) \\ Terms with n digits. For larger n, better filter primes in palindromes. - M. F. Hasler, Dec 19 2024
    
  • Python
    from itertools import chain
    from sympy import isprime
    A002385 = sorted((n for n in chain((int(str(x)+str(x)[::-1]) for x in range(1,10**5)),(int(str(x)+str(x)[-2::-1]) for x in range(1,10**5))) if isprime(n))) # Chai Wah Wu, Aug 16 2014
    
  • Python
    from sympy import isprime
    A002385 = [*filter(isprime, (int(str(x) + str(x)[-2::-1]) for x in range(10**5)))]
    A002385.insert(4, 11)  # Yunhan Shi, Mar 03 2023
    
  • Python
    from sympy import isprime
    from itertools import count, islice, product
    def A002385gen(): # generator of palprimes
        yield from [2, 3, 5, 7, 11]
        for d in count(3, 2):
            for last in "1379":
                for p in product("0123456789", repeat=d//2-1):
                    left = "".join(p)
                    for mid in [[""], "0123456789"][d&1]:
                        t = int(last + left + mid + left[::-1] + last)
                        if isprime(t):
                            yield t
    print(list(islice(A002385gen(), 46))) # Michael S. Branicky, Apr 13 2025
    
  • Sage
    [n for n in (2..18181) if is_prime(n) and Word(n.digits()).is_palindrome()] # Peter Luschny, Sep 13 2018
    

Formula

Intersection of A000040 (primes) and A002113 (palindromes).
A010051(a(n)) * A136522(a(n)) = 1. [Reinhard Zumkeller, Apr 11 2011]
Complement of A032350 in A002113. - Jonathan Sondow, Jan 02 2018

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), Oct 25 2000
Comment from A006093 moved here by Franklin T. Adams-Watters, Dec 03 2009

A002778 Numbers whose square is a palindrome.

Original entry on oeis.org

0, 1, 2, 3, 11, 22, 26, 101, 111, 121, 202, 212, 264, 307, 836, 1001, 1111, 2002, 2285, 2636, 10001, 10101, 10201, 11011, 11111, 11211, 20002, 20102, 22865, 24846, 30693, 100001, 101101, 110011, 111111, 200002, 798644, 1000001, 1001001
Offset: 1

Views

Author

Keywords

Comments

A002779(n) = a(n)^2; A136522(A000290(a(n))) = 1. - Reinhard Zumkeller, Oct 11 2011
See A016113 for the subset of numbers whose palindromic squares have an even number of digits. - M. F. Hasler, Jun 08 2014

Examples

			26^2 = 676, which is a palindrome, so 26 is in the sequence.
27^2 = 729, which is not a palindrome, so 27 is not in the sequence.
		

References

  • 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

See A003166 for binary analog.
For analogs in bases 2,3,4,5,etc. see A003166 onwards, A029984 onwards, and A263607 onwards.

Programs

  • Haskell
    a002778 n = a002778_list !! (n-1)
    a002778_list = filter ((== 1) . a136522 . (^ 2)) [0..]
    -- Reinhard Zumkeller, Oct 11 2011
    
  • Magma
    [n: n in [0..2*10^6] | Intseq(n^2) eq Reverse(Intseq(n^2))]; // Vincenzo Librandi, Apr 07 2015
    
  • Mathematica
    palsquareQ[n_] := (n2 = IntegerDigits[n^2]; n2 == Reverse[n2]); A002778 = {}; Do[ If[palsquareQ[n], Print[n]; AppendTo[A002778, n]], {n, 0, 2 * 10^6}]; A002778 (* Jean-François Alcover, Dec 01 2011 *)
    Sqrt[#]&/@Select[Range[0, 12 * 10^5]^2, # == IntegerReverse[#] &] (* The program uses the IntegerReverse function from Mathematica version 10. - Harvey P. Dale, Mar 04 2016 *)
    Select[Range[0, 1001001], PalindromeQ[#^2] &] (* Michael De Vlieger, Dec 06 2017 *)
  • PARI
    is_A002778(n)=is_A002113(n^2) \\ M. F. Hasler, Jun 08 2014
    
  • Python
    from itertools import count, islice
    def A002778_gen(): # generator of terms
        return filter(lambda k: (s:=str(k**2))[:(t:=(len(s)+1)//2)]==s[:-t-1:-1],count(0))
    A002778_list = list(islice(A002778_gen(),20)) # Chai Wah Wu, Jun 23 2022

Extensions

More terms from Patrick De Geest

A002779 Palindromic squares.

Original entry on oeis.org

0, 1, 4, 9, 121, 484, 676, 10201, 12321, 14641, 40804, 44944, 69696, 94249, 698896, 1002001, 1234321, 4008004, 5221225, 6948496, 100020001, 102030201, 104060401, 121242121, 123454321, 125686521, 400080004, 404090404, 522808225
Offset: 1

Views

Author

Keywords

Comments

These are numbers that are both squares (see A000290) and palindromes (see A002113).

Examples

			676 is included because it is both a perfect square and a palindrome.
		

References

  • 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

Programs

  • Haskell
    a002779 n = a002778_list !! (n-1)
    a002779_list = filter ((== 1) . a136522) a000290_list
    -- Reinhard Zumkeller, Oct 11 2011
    
  • Magma
    [k^2:k in [0..100000]| Intseq(k^2) eq Reverse(Intseq(k^2)) ]; // Marius A. Burtea, Oct 15 2019
    
  • Mathematica
    palindromicNumberQ = ((# // IntegerDigits // Reverse // FromDigits) == #) &; Select[Table[n^2, {n, 0, 9999}],  palindromicNumberQ] (* Herman Beeksma, Jul 14 2005 *)
    pb10Q[n_] := Module[{idn10 = IntegerDigits[n, 10]}, idn10 == Reverse[idn10]]; Select[Range[0, 19999]^2, pb10Q] (* Vincenzo Librandi, Jul 24 2014 *)
    Select[Range[0, 22999]^2, PalindromeQ] (* Requires Mathematica version 10 or later. - Harvey P. Dale, May 01 2017 *)
  • PARI
    is(n)=my(d=digits(n)); d==Vecrev(d) && issquare(n) \\ Charles R Greathouse IV, Feb 06 2017
    
  • Python
    A002779_list = [int(s) for s in (str(m**2) for m in range(10**5)) if s == s[::-1]] # Chai Wah Wu, Aug 26 2021
  • Scala
    def isPalindromic(n: BigInt): Boolean = n.toString == n.toString.reverse
      val squares = ((1: BigInt) to (1000000: BigInt)).map(n => n * n)
      squares.filter(isPalindromic()) // _Alonso del Arte, Oct 07 2019
    

Formula

From Reinhard Zumkeller, Oct 11 2011: (Start)
a(n) = A002778(n)^2.
A136522(A000290(a(n))) = 1.
A010052(a(n)) * A136522(a(n)) = 1. (End)

A029742 Nonpalindromic numbers.

Original entry on oeis.org

10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 100, 102, 103, 104, 105, 106, 107
Offset: 1

Views

Author

Keywords

Comments

Complement of A002113; A136522(a(n)) = 0.
A064834(a(n)) > 0. - Reinhard Zumkeller, Sep 18 2013

Crossrefs

Cf. A002113. Different from A031955.

Programs

  • Haskell
    a029742 n = a029742_list !! (n-1)
    a029742_list = filter ((== 0) . a136522) [1..]
    -- Reinhard Zumkeller, Oct 09 2011
    
  • Magma
    [n: n in [0..150] | Intseq(n) ne Reverse(Intseq(n))]; // Bruno Berselli, Apr 01 2015
    
  • Mathematica
    palQ[n_]:=Module[{idn=IntegerDigits[n]},idn==Reverse[idn]]; DeleteCases[ Range[10,110],?palQ] (* _Harvey P. Dale, Jan 28 2012 *)
    Table[If[PalindromeQ[n],Nothing,n],{n,120}] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jul 13 2019 *)
  • PARI
    is(n)=my(d=digits(n)); d!=Vecrev(d) \\ Charles R Greathouse IV, Feb 06 2017
    
  • Python
    def ok(n): s = str(n); return s != s[::-1]
    print(list(filter(ok, range(108)))) # Michael S. Branicky, Oct 12 2021
    
  • Python
    def A029742(n):
        def f(x): return n+x//10**((l:=len(s:=str(x)))-(k:=l+1>>1))-(int(s[k-1::-1])>x%10**k)+10**(k-1+(l&1^1))-1
        m, k = n, f(n)
        while m != k:
            m, k = k, f(k)
        return m # Chai Wah Wu, Jul 24 2024

Extensions

Offset corrected by Reinhard Zumkeller, Oct 09 2011

A033620 Numbers all of whose prime factors are palindromes.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 27, 28, 30, 32, 33, 35, 36, 40, 42, 44, 45, 48, 49, 50, 54, 55, 56, 60, 63, 64, 66, 70, 72, 75, 77, 80, 81, 84, 88, 90, 96, 98, 99, 100, 101, 105, 108, 110, 112, 120, 121, 125, 126, 128, 131
Offset: 1

Views

Author

N. J. A. Sloane, May 17 1998

Keywords

Comments

Multiplicative closure of A002385; A051038 and A046368 are subsequences. - Reinhard Zumkeller, Apr 11 2011

Examples

			10 = 2 * 5 is a term since both 2 and 5 are palindromes.
110 = 2 * 5 * 11 is a term since 2, 5 and 11 are palindromes.
		

Crossrefs

Programs

  • Haskell
    a033620 n = a033620_list !! (n-1)
    a033620_list = filter chi [1..] where
       chi n = a136522 spf == 1 && (n' == 1 || chi n') where
          n' = n `div` spf
          spf = a020639 n  -- cf. A020639
    -- Reinhard Zumkeller, Apr 11 2011
    
  • Maple
    N:= 5: # to get all terms of up to N digits
    digrev:= proc(t) local L; L:= convert(t,base,10);
    add(L[-i-1]*10^i,i=0..nops(L)-1);
    end proc:
    PPrimes:= [2,3,5,7,11]:
    for d from 3 to N by 2 do
        m:= (d-1)/2;
        PPrimes:= PPrimes, select(isprime,[seq(seq(n*10^(m+1)+y*10^m+digrev(n), y=0..9), n=10^(m-1)..10^m-1)]);
    od:
    PPrimes:= map(op,[PPrimes]):
    M:= 10^N:
    B:= Vector(M);
    B[1]:= 1:
    for p in PPrimes do
      for k from 1 to floor(log[p](M)) do
         R:= [$1..floor(M/p^k)];
         B[p^k*R] := B[p^k*R] + B[R]
      od
    od:
    select(t -> B[t] > 0, [$1..M]); # Robert Israel, Jul 05 2015
    # alternative
    isA033620:= proc(n)
        for d in numtheory[factorset](n) do
            if not isA002113(op(1,d)) then
                return false;
            end if;
        end do;
        true ;
    end proc:
    for n from 1 to 300 do
        if isA033620(n) then
            printf("%d,",n) ;
        end if;
    end do: # R. J. Mathar, Sep 09 2015
  • Mathematica
    palQ[n_]:=Reverse[x=IntegerDigits[n]]==x; Select[Range[131],And@@palQ/@First/@FactorInteger[#]&] (* Jayanta Basu, Jun 05 2013 *)
  • PARI
    ispal(n)=n=digits(n);for(i=1,#n\2,if(n[i]!=n[#n+1-i],return(0)));1
    is(n)=if(n<13,n>0,vecmin(apply(ispal,factor(n)[,1]))) \\ Charles R Greathouse IV, Feb 06 2013
    
  • Python
    from sympy import isprime, primefactors
    def pal(n): s = str(n); return s == s[::-1]
    def ok(n): return all(pal(f) for f in primefactors(n))
    print(list(filter(ok, range(1, 132)))) # Michael S. Branicky, Apr 06 2021

Formula

Sum_{n>=1} 1/a(n) = Product_{p in A002385} p/(p-1) = 5.0949... - Amiram Eldar, Sep 27 2020

A178225 Characteristic function of A006995 (binary palindromes).

Original entry on oeis.org

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

Views

Author

Jeremy Gardiner, May 23 2010

Keywords

Comments

a(n)=1 if n is in A006995, a(n)=0 otherwise.
For n<43, identical to parity of A175096.
Comment by Franklin T. Adams-Watters: (Start)
Any permutation of the runs of n gives another such permutation when reversed. This pairs up all non-palindromic permutations of the runs of n. Thus the parity of A175096(n) is the parity of the number of palindromic run-permutations of n. For small n, this is 1 when n is a binary palindrome, and 0 otherwise.
The first exception is 43, binary 101011, which has a nontrivial palindromic run-permutation 45, binary 101101. Another kind of exception occurs first for n = 365, binary 101101101, which is a palindrome, but has another palindromic run-permutation 427, binary 110101011. (End)
Given an index n such that a(n)=1, then the following A164126(A206915(n))-1 terms will be 0. n'=A164126(A206915(n)) is the next term with a(n')=1. Therefore, if we subtract 1 from each term of A164126, we get the sequence of run lengths of 0's. - Hieronymus Fischer, Feb 19 2012.
Given an index n such that a(n)=0, then p=A206913(n) is the greatest index pA206914(n) is the least index q>n such that a(q)=1, which implies a(k)=0 for all k with n<=kHieronymus Fischer, Feb 19 2012.
Binary palindromes are distributed symmetrically with respect to threefold multiples of powers of 2. This becomes obvious by the generating function g(x) below. Example for the resulting factors of x^(3*2^5)=x^96: the factors are x^q and x^(-q) for q=3,11,23,31. Thus, the palindromes are 96+3, 96-3, 96+11, 96-11, 96+23, 96-23, 96+31, 96-31. The respective number of palindromes with this property is 2^(floor(m/2)), where m is the exponent of the corresponding power of 2. - Hieronymus Fischer, Apr 04 2012

Examples

			a(3)=1, since 3 is binary palindromic;
a(4)=0, since 4 is not palindromic.
		

Crossrefs

Cf. A136522. See A206915 for the partial sums.

Programs

  • Haskell
    a178225 n = fromEnum $ n == a030101 n  -- Reinhard Zumkeller, Oct 21 2011
    
  • Mathematica
    A178225[n_]:=Boole[PalindromeQ[IntegerDigits[n,2]]];
    Array[A178225,100,0] (* Paolo Xausa, Oct 15 2023 *)
  • PARI
    a(n) = my(b=binary(n)); b == Vecrev(b); \\ Michel Marcus, Feb 13 2019
    
  • Python
    a187225 = lambda n: int(bin(n)[2:] == bin(n)[:1:-1]) # David Radcliffe, May 05 2023

Formula

a(A006995(n)) = 1; a(A154809(n)) = 0. - Reinhard Zumkeller, Oct 21 2011
a(n) = if A030101(n) = n then 1, otherwise 0. - Reinhard Zumkeller, Jan 17 2012
a(n) = 1 - (A206916(n) - A206915(n)). - Hieronymus Fischer, Feb 18 2012
G.f.: g(x) = 1 + x + x^3 + Sum{j>=1} x^(3*2^j)*(f_j(x)+f_j(1/x)), where the f_j(x) are defined as follows:
f_1(x)=x, and for j > 1,
f_j(x) = x^3*Product_{k=1..floor((j-1)/2)} (1+x^b(j,k)), where b(j,k) = 2^(floor((j-1)/2)-k)*((3+(-1)^j)*2^(2*k+1)+4) for k > 1, and b(j,1) = (2+(-1)^j)*2^(floor((j-1)/2)+1). The first explicit terms of this g.f. are
g(x) = 1 + x + x^3 + (f_1(x) + f_1(1/x))*x^6 + (f_2(x) + f_2(1/x))*x^12 + (f_3(x)+f_3(1/x))*x^24 + (f_4(x) + f_4(1/x))*x^48 + (f_5(x) + f_5(1/x))*x^96 + ... = 1 + x + x^3 + (x+1/x)*x^6 + (x^3+1/x^3)*x^12 + (x^3*(1+x^4) + (1+1/x^4)/x^3)*x^24 + (x^3*(1+x^12) + (1+1/x^12)/x^3)*x^48 + (x^3*(1+x^8)(1+x^20) + (1+1/x^20)(1+1/x^8)/x^3)*x^96 + ... - Hieronymus Fischer, Apr 02 2012

A061917 Either a palindrome or becomes a palindrome if trailing 0's are omitted.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 20, 22, 30, 33, 40, 44, 50, 55, 60, 66, 70, 77, 80, 88, 90, 99, 100, 101, 110, 111, 121, 131, 141, 151, 161, 171, 181, 191, 200, 202, 212, 220, 222, 232, 242, 252, 262, 272, 282, 292, 300, 303, 313, 323, 330, 333, 343, 353, 363, 373, 383, 393, 400, 404
Offset: 1

Views

Author

N. J. A. Sloane, Jun 27 2001

Keywords

Comments

Numbers that are palindromes when written with a suitable number of leading zeros. - Jeppe Stig Nielsen, Jan 17 2022

Crossrefs

Programs

  • Haskell
    a061917 n = a061917_list !! (n-1)
    a061917_list = filter chi [0..] where
       chi x = zs == reverse zs where
          zs = dropWhile (== '0') $ reverse $ show x
    -- Reinhard Zumkeller, Sep 25 2011
    
  • Mathematica
    PaleQ[n_Integer, base_Integer] := Module[{idn, trim = n/base^IntegerExponent[n, base]}, idn = IntegerDigits[trim, base]; idn == Reverse[idn]]; Select[Range[0, 500], PaleQ[#, 10] &] (* Lei Zhou, Dec 13 2013 *)
    Join[{0},Select[Range[500],PalindromeQ[FromDigits[Drop[IntegerDigits[#],-IntegerExponent[#,10]]]]&]] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, May 27 2017 *)
  • PARI
    isOK(k)=k==0||fromdigits(Vecrev(digits(k)))==k/10^valuation(k,10) \\ Jeppe Stig Nielsen, Jan 17 2022
    
  • Python
    def ispal(s): return s == s[::-1]
    def ok(n): s = str(n); return ispal(s) or ispal(s.rstrip('0'))
    print([k for k in range(405) if ok(k)]) # Michael S. Branicky, Jan 17 2022

Formula

A136522(A004151(a(n))) = 1. - Reinhard Zumkeller, Sep 25 2011

Extensions

Corrected by Ray Chandler, Jun 08 2009

A131428 a(n) = 2*C(n) - 1, where C(n) = A000108(n) are the Catalan numbers.

Original entry on oeis.org

1, 1, 3, 9, 27, 83, 263, 857, 2859, 9723, 33591, 117571, 416023, 1485799, 5348879, 19389689, 70715339, 259289579, 955277399, 3534526379, 13128240839, 48932534039, 182965127279, 686119227299, 2579808294647, 9723892802903, 36734706144303, 139067101832007
Offset: 0

Views

Author

Gary W. Adamson, Jul 10 2007

Keywords

Comments

Starting (1, 3, 9, 27, 83, ...), = row sums of triangle A136522. - Gary W. Adamson, Jan 02 2008
Hankel transform is A171552. - Paul Barry, Dec 11 2009
Apparently, for n >= 1, the maximum peak height minus the maximum valley height summed over all Dyck n-paths (with max valley height deemed zero if no valleys). - David Scambler, Oct 05 2012
Apparently for n > 1 the number of fixed points in all Dyck (n-1)-paths. A fixed point occurs when a vertex of a Dyck k-path is also a vertex of the path U^kD^k. - David Scambler, May 01 2013

Examples

			a(3) = 9 = 2*C(3) - 1 = 2*5 - 1, where C refers to the Catalan numbers, A000108.
		

Crossrefs

Programs

  • GAP
    List([0..25], n-> 2*Binomial(2*n,n)/(n+1) - 1); # G. C. Greubel, Aug 12 2019
  • Magma
    [2*Catalan(n) -1: n in [0..25]]; // G. C. Greubel, Aug 12 2019
    
  • Maple
    seq(2*binomial(2*n,n)/(n+1)-1, n=0..25); # Emeric Deutsch, Jul 25 2007
  • Mathematica
    2CatalanNumber[Range[0,25]]-1  (* Harvey P. Dale, Apr 17 2011 *)
  • PARI
    vector(25, n, n--; 2*binomial(2*n,n)/(n+1) - 1) \\ G. C. Greubel, Aug 12 2019
    
  • Sage
    [2*catalan_number(n) -1 for n in (0..25)] # G. C. Greubel, Aug 12 2019
    

Formula

Right border of triangle A131429.
From Emeric Deutsch, Jul 25 2007: (Start)
a(n) = 2*binomial(2*n,n)/(n+1) - 1.
G.f.: (1-sqrt(1-4*x))/x - 1/(1-x). (End)
(1, 3, 9, 27, 83, ...) = row sums of A118976. - Gary W. Adamson, Aug 31 2007
Row sums of triangle A131428 starting (1, 3, 9, 27, 83, ...). - Gary W. Adamson, Aug 31 2007
Starting with offset 1 = Narayana transform (A001263) of [1,2,2,2,...]. - Gary W. Adamson, Jul 29 2011
D-finite with recurrence (n+1)*a(n) +2*(-2*n+1)*a(n-1) +3*(-n+1)=0. - R. J. Mathar, Nov 22 2024
a(n) = Sum_{k=0..n} ( binomial(n,k) - binomial(n,k-1) )^2 = Sum_{k=0..n} A080233(n,k)^2 = Sum_{k=0..n} A156644(n,k)^2. - Seiichi Manyama, Mar 25 2025

Extensions

More terms from Emeric Deutsch, Jul 25 2007

A134810 Giza numbers.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 8, 9, 121, 232, 343, 454, 565, 676, 787, 898, 12321, 23432, 34543, 45654, 56765, 67876, 78987, 1234321, 2345432, 3456543, 4567654, 5678765, 6789876, 123454321, 234565432, 345676543, 456787654, 567898765, 12345654321, 23456765432
Offset: 1

Views

Author

Omar E. Pol, Nov 25 2007, Nov 26 2007

Keywords

Comments

For n > 9 the structure of digits represents the pyramids of Giza. Also the top of a mountain. The first digit is equal to the last digit. The first digits are in consecutive increasing order. The last digits are in consecutive decreasing order. The largest digit is the central digit. The number of digits is odd. This sequence has 45 terms. The final term is 12345678987654321. Giza numbers are mountain numbers A134941 and palindromes A002113.
There are 10 - k numbers with 2*k - 1 digits. - Omar E. Pol, Aug 04 2011

Examples

			Illustration using the final term of this sequence:
  . . . . . . . . 9 . . . . . . . .
  . . . . . . . 8 . 8 . . . . . . .
  . . . . . . 7 . . . 7 . . . . . .
  . . . . . 6 . . . . . 6 . . . . .
  . . . . 5 . . . . . . . 5 . . . .
  . . . 4 . . . . . . . . . 4 . . .
  . . 3 . . . . . . . . . . . 3 . .
  . 2 . . . . . . . . . . . . . 2 .
  1 . . . . . . . . . . . . . . . 1
		

Crossrefs

Programs

  • Mathematica
    ups = Flatten[Table[Range[i, j - 1], {i, 1, 9}, {j, i + 1, 10}], 1];afull = Sort[  Map[ToExpression@StringJoin@Map[ToString, #[[;; -2]] ~Join~ Reverse[#]] &, ups]];afull (* James C. McMahon, Apr 11 2025 *)
  • Python
    ups = [tuple(range(i, j)) for i in range(1, 10) for j in range(i+1, 11)]
    afull = sorted(int("".join(map(str, u[:-1] + u[::-1]))) for u in ups)
    print(afull) # Michael S. Branicky, Aug 02 2022

Formula

A178333(a(n))*A136522(a(n)) = 1. - Reinhard Zumkeller, May 25 2010
Showing 1-10 of 55 results. Next