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.

A342803 Primes p whose palindromization A082216(p) is a square or higher power.

Original entry on oeis.org

67, 449, 1367, 10303, 12343, 1003003, 1022141, 1230127, 1234543, 4004009, 121200307, 10022234347, 10201204021, 10203242527, 12100242001, 13310399303, 16151080151, 52281509069, 61584539747, 90608667517, 104190107303, 1020102040201, 1022143262341, 12384043938083
Offset: 1

Views

Author

Lamine Ngom, Mar 22 2021

Keywords

Comments

Palindromization is the function that minimally extends the string representation of a number into a palindrome (see A082216).
Are 13 and 1367 the unique terms leading to cubes or higher powers?
It seems that 13 is the unique prime whose even palindromization (the concatenation of a number and its reversal) is a square or higher power.
The next term (if it exists) is greater than 10^17.

Examples

			The prime 449 belongs to sequence because 44944 is a square: 212^2.
The prime 1367 is in the sequence since 1367631 is a cube: 111^3.
The prime 13 is not a term as A082216(13) = 131 and 131 is prime. The prime 10303 is in the sequence since 1030301 is a cube: 101^3. - _Chai Wah Wu_, Aug 26 2021
		

Crossrefs

Cf. A082216 (smallest palindrome beginning with n).
Subsequence of primes of A342942.

Programs

  • Mathematica
    Select[Prime@Range@100000,Or@@(GCD@@Last/@FactorInteger@#>1&/@(FromDigits/@(Join[a,Reverse@#]&/@{a=IntegerDigits@#,Most@a})))&] (* Giorgos Kalogeropoulos, Mar 31 2021 *)

Extensions

Corrected terms and missing terms added by Chai Wah Wu, Aug 26 2021

A056544 Smallest palindrome containing the digits of n as a subsequence.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 8, 9, 101, 11, 121, 131, 141, 151, 161, 171, 181, 191, 202, 121, 22, 232, 242, 252, 262, 272, 282, 292, 303, 131, 232, 33, 343, 353, 363, 373, 383, 393, 404, 141, 242, 343, 44, 454, 464, 474, 484, 494, 505, 151, 252, 353, 454, 55, 565, 575
Offset: 1

Views

Author

Joseph L. Pe, Feb 10 2002

Keywords

Examples

			The smallest palindrome containing 21 as a subsequence is 121. So a(21) = 121.
		

Crossrefs

Cf. A002113, A082216, A145800 (binary variant).

Programs

  • Mathematica
    Do[k = 1; While[ StringPosition[ ToString[k], ToString[n]] == {} || ToString[k] != StringReverse[ ToString[k]], k++ ]; Print[k], {n, 1, 70} ]
  • PARI
    See Links section.

Formula

a(A002113(n)) = A002113(n). - Chai Wah Wu, Apr 13 2021

Extensions

Edited and extended by Robert G. Wilson v, Feb 12 2002

A161501 a(n) is the smallest positive integer that is a palindrome when represented in binary, and is made by appending some number (zero or more) of binary digits on the right of n's binary representation.

Original entry on oeis.org

1, 5, 3, 9, 5, 27, 7, 17, 9, 21, 45, 51, 27, 119, 15, 33, 17, 73, 153, 165, 21, 45, 93, 99, 51, 107, 27, 231, 119, 495, 31, 65, 33, 273, 561, 73, 297, 153, 313, 325, 165, 85, 693, 717, 45, 93, 189, 195, 99, 403, 51, 843, 107, 219, 443, 455, 231, 471, 119, 975, 495, 2015
Offset: 1

Views

Author

Leroy Quet, Jun 11 2009

Keywords

Examples

			11 (decimal) in binary is 1011. Appending 01 to the right side of 1011 forms the binary palindrome 101101, which is 45 in decimal. Since two binary digits is the smallest number of digits that need to be appended to form a palindrome, then a(11) = 45. (Note that 45 is not the smallest positive number that when represented in binary is a palindrome and contains 1011 as a substring. That would instead be 11011 {binary} = 27 {decimal}.)
		

Crossrefs

Cf. A006995, A082216 (decimal variant), A145800, A161502.

Programs

  • PARI
    a(n, base=2) = { my (b=digits(n, base)); if (b==Vecrev(b), return (n), my (t=[]); for (k=1, #b, t=concat(b[k],t); my (bt=concat(b,t)); if (bt==Vecrev(bt), return (fromdigits(bt, base))))) } \\ Rémy Sigrist, Mar 22 2020
    
  • Python
    def A161501(n):
        s = bin(n)[2:]
        if s == s[::-1]:
            return n
        for i in range(1,len(s)):
            if s[i:] == s[-1:i-1:-1]:
                return int(s+s[i-1::-1],2) # Chai Wah Wu, Aug 27 2021

Extensions

More terms from Sean A. Irvine, Sep 27 2009

A347336 Lexicographically earliest sequence of distinct positive integers such that the concatenation of a(n) and a(n+1) added to a(n+2) is a palindrome in base 10.

Original entry on oeis.org

1, 2, 10, 12, 99, 32, 67, 66, 120, 46, 75, 209, 48, 64, 20, 26, 86, 196, 72, 19, 8, 4, 15, 9, 22, 7, 5, 13, 42, 319, 105, 808, 793, 1115, 282, 829, 553, 375, 1080, 493, 308, 1186, 617, 194, 522, 1069, 156, 445, 206, 338, 264, 569, 993, 82, 17, 11, 60, 61, 55, 71, 94, 33, 16, 127, 34, 87
Offset: 1

Views

Author

Eric Angelini and Carole Dubois, Aug 28 2021

Keywords

Examples

			[a(1), a(2)] + a(3) = [1, 2] + 10 = 12 + 10 = 22 (palindrome);
[a(2), a(3)] + a(4) = [2, 10] + 12 = 210 + 12 = 222 (palindrome);
[a(3), a(4)] + a(5) = [10, 12] + 99 = 1012 + 99 = 1111 (palindrome);
[a(4), a(5)] + a(6) = [12, 99] + 32 = 1299 + 32 = 1331 (palindrome); etc.
		

Crossrefs

Programs

  • Python
    def ispal(n): s = str(n); return s == s[::-1]
    def aupton(terms):
        alst, seen = [1, 2], {1, 2}
        for n in range(2, terms):
            an, partial_sum = 1, int(str(alst[-2]) + str(alst[-1]))
            while an in seen or not ispal(partial_sum + an): an += 1
            alst.append(an); seen.add(an)
        return alst
    print(aupton(66)) # Michael S. Branicky, Aug 28 2021

A347346 Smallest palindrome ending with n or 0 if n is a multiple of 10.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 212, 313, 414, 515, 616, 717, 818, 919, 0, 121, 22, 323, 424, 525, 626, 727, 828, 929, 0, 131, 232, 33, 434, 535, 636, 737, 838, 939, 0, 141, 242, 343, 44, 545, 646, 747, 848, 949, 0, 151, 252, 353, 454, 55, 656, 757, 858, 959
Offset: 1

Views

Author

Chai Wah Wu, Aug 27 2021

Keywords

Crossrefs

Programs

  • Python
    def A347346(n):
        if n % 10 == 0:
            return 0
        s = str(n)
        if s == s[::-1]:
            return n
        for i in range(1,len(s)):
            if s[:-i]== s[-i-1::-1]:
                return int(s[:-i-1:-1]+s)

Formula

If n is not a multiple of 10, then a(n) = A082216(A004086(n)).

A366198 Any a(n) replacing the first digit of a(n+1) forms a palindrome. This is the lexicographically earliest sequence of distinct nonnegative integers with this property.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 19, 11, 21, 12, 31, 13, 41, 14, 51, 15, 61, 16, 71, 17, 81, 18, 91, 29, 22, 32, 23, 42, 24, 52, 25, 62, 26, 72, 27, 82, 28, 92, 39, 33, 43, 34, 53, 35, 63, 36, 73, 37, 83, 38, 93, 49, 44, 54, 45, 64, 46, 74, 47, 84, 48, 94, 59, 55, 65, 56, 75, 57, 85, 58, 95
Offset: 1

Views

Author

Eric Angelini, Oct 03 2023

Keywords

Comments

No integer > 1 ending in zero will appear in the sequence.
For n >= 10 the concatenation of a(n) and A217657(a(n+1)) is a palindrome.

Examples

			a(9)  =  8 replacing the first digit of a(10) =  9 forms   8, a palindrome;
a(10) =  9 replacing the first digit of a(11) = 19 forms  99, a palindrome;
a(11) = 19 replacing the first digit of a(12) = 11 forms 191, a palindrome;
a(12) = 11 replacing the first digit of a(13) = 21 forms 111, a palindrome;
a(13) = 21 replacing the first digit of a(14) = 12 forms 212, a palindrome; etc.
		

Crossrefs

Programs

  • Mathematica
    terms=75; b[0]=0;
    b[n_]:=b[n]=(k=1; While[MemberQ[Array[b,n-1],k]||!PalindromeQ[FromDigits@Flatten@ReplacePart[IntegerDigits@k,1-> IntegerDigits@b[n-1]]],k++]; k); t=0;While[Length[a=Join[Range[0,9],Flatten@Table[FromDigits@Flatten@Insert[#,Table[9,i],-2]&/@(IntegerDigits/@Array[b,9^2,10]),{i,0,t++}]]]Giorgos Kalogeropoulos, Oct 04 2023 *)
  • Python
    from itertools import count, islice
    def ispal(n): return (s:=str(n))==s[::-1]
    def agen(): # generator of terms
        an, seen = 0, set()
        while True:
            yield an; seen.add(an); s = str(an)
            an = next(k for k in count(0) if k not in seen and ispal(s+str(k)[1:]))
    print(list(islice(agen(), 80))) # Michael S. Branicky, Oct 04 2023
    
  • Python
    # faster version suitable for generating b-file
    from sympy import isprime
    from itertools import count, islice, product
    def pals(digs):
        yield from digs
        for d in count(2):
            for p in product(digs, repeat=d//2):
                left = "".join(p)
                for mid in [[""], digs][d%2]:
                    yield left + mid + left[::-1]
    def folds(s): # generator of suffixes of palindromes starting with s
        for i in range((len(s)+1)//2, len(s)+1):
            for mid in [True, False]:
                t = s[:i] + (s[:i-1][::-1] if mid else s[:i][::-1])
                if t.startswith(s):
                    yield t[len(s):]
        yield from ("".join(p)+s[::-1] for p in pals("0123456789"))
    def agen():
        s, seen = "0", {"0"}
        while True:
            yield int(s)
            found = False
            for end in folds(s):
                for start in "123456789":
                    t = start + end
                    if t not in seen:
                        found = True; break
                if found: break
            s, seen = t, seen | {t}
    print(list(islice(agen(), 60))) # Michael S. Branicky, Oct 04 2023

Formula

For n >= 92, a(n) = 10*a(n-81) + 90 - 9*(a(n-81) mod 10). - David A. Corneth, Oct 04 2023

A082217 Smallest palindrome beginning with n and digit sum n, or 0 if no such number exists.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 8, 9, 10801, 11711, 12621, 13531, 14441, 15351, 16261, 17171, 1881, 0, 208802, 2139312, 227722, 2329232, 246642, 2519152, 265562
Offset: 1

Views

Author

Amarnath Murthy and Meenakshi Shrikant (menakan_s(AT)yahoo.com), Apr 09 2003

Keywords

Comments

a(19) = 0. This is the only zero in the sequence. Every other integer k > 9 has digit sum <= k/2, so the center can always be filled in to make a palindrome.

Crossrefs

A185267 Smallest palindrome beginning with n-th prime.

Original entry on oeis.org

2, 3, 5, 7, 11, 131, 171, 191, 232, 292, 313, 373, 414, 434, 474, 535, 595, 616, 676, 717, 737, 797, 838, 898, 979, 101, 10301, 10701, 10901, 11311, 12721, 131, 13731, 13931, 14941, 151, 15751, 16361, 16761, 17371, 17971, 181, 191, 19391, 19791, 1991, 2112, 22322
Offset: 1

Views

Author

Jonathan Vos Post, Feb 19 2011

Keywords

Comments

a(n) is itself prime for n = 1, 2, 3, 4, 5, 6, 8, 11, 12, 22, 26, 27, 30, 31, 32, 34, ... where a(n) = 2, 3, 5, 7, 11, 131, 191, 313, 373, 797, 101, 10301, 11311, 12721, 131, 13931, which are also in A002385. Although 979 begins with the prime p(25) = 97, and is a palindrome, it is not in the commented subsequence because 979 = 11 * 89 is semiprime rather than prime.

Examples

			a(6) = 131 because that is the smallest palindrome beginning (base 10) with p(6) = 13.
		

Crossrefs

Programs

  • Python
    from sympy import prime
    def A185267(n):
        p = prime(n)
        s = str(p)
        if s == s[::-1]:
            return p
        for i in range(1,len(s)):
            if s[i:] == s[-1:i-1:-1]:
                return int(s+s[i-1::-1]) # Chai Wah Wu, Aug 27 2021

Formula

a(n) = A082216(A000040(n)).
Showing 1-8 of 8 results.