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.

A382898 Beginning with 13, least prime such that concatenation of first n terms and its digit reversal both are primes.

Original entry on oeis.org

13, 151, 227, 2083, 887, 79, 2963, 1579, 6287, 1321, 6719, 54919, 26699, 8647, 4229, 3919, 102161, 42433, 1667, 192193, 11633, 186343, 47339, 3259, 65963, 14293, 29717, 61297, 28493, 231367, 43793, 145021, 566441, 475903, 92381, 80473, 139967, 882061, 72893, 709279, 6053, 114487, 1179389, 204331, 203351, 139831, 396239, 205327, 501173, 951589
Offset: 1

Views

Author

J.W.L. (Jan) Eerland, Apr 08 2025

Keywords

Crossrefs

Cf. A113584 (same for 3), A379761 (same for 7), A380227 (same for 11).

Programs

  • Maple
    rev:= proc(n) local L,i;
      L:= convert(n,base,10);
      add(L[-i]*10^(i-1),i=1..nops(L))
    end proc:
    tcat:= proc(a,b)
      a*10^(1+ilog10(b))+b
    end proc:
    A:= 13: x:= 13:
    for i from 1 to 50 do
       p:= 2:
       do
         p:= nextprime(p);
         y:= tcat(x,p);
         if isprime(y) and isprime(rev(y)) then
              A:= A,p;
              x:= y;
              break
         fi;
       od
    od:
    A; # after Robert Israel in A113584
  • Mathematica
    w={13};Do[k=1;q=Monitor[Parallelize[While[True,If[PrimeQ[FromDigits[Join@@IntegerDigits/@Reverse[IntegerDigits[FromDigits[Join@@IntegerDigits/@Append[w,Prime[k]]]]]]]&&PrimeQ[FromDigits[Join@@IntegerDigits/@Append[w,Prime[k]]]],Break[]];k++];Prime[k]],{i,k}];w=Append[w,q],{i,2,50}];w
  • Python
    from itertools import count, islice
    from gmpy2 import digits, is_prime, mpz, next_prime
    def agen(): # generator of terms
        s, r, an = "", "", 13
        while True:
            yield int(an)
            d = digits(an)
            s, r, p, sp = s+d, d[::-1]+r, 3, "3"
            while not is_prime(mpz(s+sp)) or not is_prime(mpz(sp[::-1]+r)):
                p = next_prime(p)
                sp = digits(p)
            an = p
    print(list(islice(agen(), 40))) # after Michael S. Branicky in A113584