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

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

A318533 Lexicographically first sequence of distinct positive integers such that a(n) + [the first digit of a(n+1)] is a palindrome in base 10.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 10, 13, 9, 20, 21, 14, 8, 15, 7, 16, 60, 61, 50, 51, 40, 41, 30, 31, 24, 90, 91, 80, 81, 70, 71, 62, 42, 25, 82, 63, 32, 17, 52, 35, 92, 72, 53, 26, 73, 43, 18, 46, 93, 64, 27, 65, 19, 36, 83, 54, 100, 102, 94, 57, 95, 47, 84, 48, 74, 37, 75, 28, 58, 85, 38, 68, 96, 39, 59, 76, 103, 86, 29, 49, 69, 87, 104
Offset: 1

Views

Author

Eric Angelini and Jean-Marc Falcoz, Aug 28 2018

Keywords

Examples

			The sequence starts with 1,2,3,4,5,6,10,13,9,... and we see that [1 + (the first digit of 2)] is a palindrome (3); [2 + (the first digit of 3)] is a palindrome (5); [3 + (the first digit of 4)] is a palindrome (7); [4 + (the first digit of 5)] is a palindrome (9); [5 + (the first digit of 6)] is a palindrome (11); [6 + (the first digit of 10)] is a palindrome (7); [10 + (the first digit of 13)] is a palindrome (11); [13 + (the first digit of 9)] is a palindrome (22); etc.
		

Crossrefs

Cf. A318486 for a subtraction of the first digit of a(n+1) instead of the addition.

A366197 Lexicographically earliest permutation of the nonnegative integers such that the absolute difference between the digitsum of a(n) and the digitsum of a(n+2) = 1.

Original entry on oeis.org

0, 1, 10, 2, 11, 3, 12, 4, 13, 5, 14, 6, 15, 7, 16, 8, 17, 9, 18, 19, 26, 27, 25, 28, 24, 29, 23, 37, 22, 36, 21, 35, 20, 34, 30, 33, 31, 32, 41, 40, 42, 50, 43, 51, 44, 52, 45, 53, 46, 54, 38, 55, 39, 47, 49, 48, 57, 56, 58, 64, 59, 63, 67, 62, 66, 61, 65, 60
Offset: 0

Views

Author

Eric Angelini, Oct 03 2023

Keywords

Examples

			DS stands hereunder for DigitSum:
a(0) =  0 (DS 0) and a(2) = 10 (DS 1) and the absolute difference 0 - 1 = 1;
a(1) =  1 (DS 1) and a(3) =  2 (DS 2) and the absolute difference 1 - 2 = 1;
a(2) = 10 (DS 1) and a(4) = 11 (DS 2) and the absolute difference 1 - 2 = 1;
a(3) =  2 (DS 2) and a(5) =  3 (DS 3) and the absolute difference 2 - 3 = 1;
a(4) = 11 (DS 2) and a(6) = 12 (DS 3) and the absolute difference 2 - 3 = 1; etc.
		

Crossrefs

Programs

  • Python
    from itertools import count, filterfalse
    def DS(y):
        z = str(y)
        return sum(int(z[i]) for i in range (0,len(z)))
    def A366197_list(n_max):
        A = [0,1]
        S = set(A)
        for n in range(2,n_max+1):
            for i in filterfalse(S._contains_, count(1)):
                if abs(DS(A[n-2])-DS(i)) == 1:
                    A.append(i)
                    S.add(i)
                    break
        return(A) # John Tyler Rascoe, Oct 22 2023

Extensions

More terms from Alois P. Heinz, Oct 03 2023
Showing 1-3 of 3 results.