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.

A382927 Smallest beginning of a sequence of exactly n consecutive palindromic primes, all ending with the same digit.

Original entry on oeis.org

2, 181, 151, 131, 101, 11, 17471, 16661, 16561, 16361, 16061, 15551, 15451, 14741, 14341, 13931, 13831, 13331, 12821, 12721, 12421, 11411, 11311, 10601, 10501, 10301, 1884881, 1883881, 1881881, 1880881, 1879781, 1878781, 1876781, 1865681, 1856581, 1853581, 1851581
Offset: 1

Views

Author

Jean-Marc Rebert, Apr 13 2025

Keywords

Examples

			a(6) = 11, because 11 initiates a sequence of exactly six consecutive palindromic primes: 11, 101, 131, 151, 181 and 191, each ending in the same digit 1.
		

Crossrefs

Programs

  • Maple
    # with A002385 e.g. from the b-file for that sequence
    R:= NULL:
    d:= 2: count:= 1: m:= 1;
    for i from 2 while m < 100 do
      dp:= A002385[i] mod 10;
      if d = dp then count:= count+1
      else
        d:= dp;
        if count >= m then
          R:= R, seq(A002385[i-j],j=m..count);
          m:= count+1;
        fi;
        count:= 1;
      fi
    od:
    R; # Robert Israel, May 13 2025
  • Python
    from sympy import isprime
    from itertools import count, islice, product
    def palprimes(): # 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
    def agen(): # generator of terms
        adict, n, lastdigit, vlst = dict(), 1, 0, [2]
        for p in palprimes():
            if p%10 == lastdigit:
                vlst.append(p)
            else:
                if len(vlst) >= n:
                    for i in range(n, len(vlst)+1):
                        if i not in adict:
                            adict[i] = vlst[-i]
                    while n in adict: yield adict[n]; n += 1
                lastdigit, vlst = p%10, [p]
    print(list(islice(agen(), 40))) # Michael S. Branicky, Apr 13 2025