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.

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

Original entry on oeis.org

3, 7, 3, 3, 43, 101, 19, 269, 1873, 41, 241, 3137, 139, 9011, 9187, 641, 29881, 12227, 3169, 13499, 8539, 7019, 19447, 12899, 73243, 124769, 1063, 37847, 127, 32321, 104287, 3407, 93553, 256643, 165469, 744659, 60217, 54773, 49297, 214457, 314077, 271409, 602383, 56921, 193051, 255383, 75991, 25667, 583147, 121019
Offset: 1

Views

Author

Amarnath Murthy, Nov 06 2005

Keywords

Crossrefs

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:= 3: x:= 3:
    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; # Robert Israel, Dec 26 2024
  • Mathematica
    w = {3};
    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]], k];
      w = Append[w, q], {i, 2, 50}];
    w (* J.W.L. (Jan) Eerland, Dec 19 2024 *)
  • Python
    from itertools import count, islice
    from gmpy2 import digits, is_prime, mpz, next_prime
    def agen(): # generator of terms
        s, r, an = "", "", 3
        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(), 50))) # Michael S. Branicky, Jan 02 2025

Extensions

Corrected and extended by Hans Havermann, Nov 08 2005
a(40)-a(50) from J.W.L. (Jan) Eerland, Dec 19 2024