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.

A273802 Prime numbers formed by successively prepending prime numbers to 3.

Original entry on oeis.org

3, 53, 1153, 311153, 101311153, 271101311153, 347271101311153, 631347271101311153, 719631347271101311153, 829719631347271101311153, 1031829719631347271101311153, 11231031829719631347271101311153, 125911231031829719631347271101311153, 1801125911231031829719631347271101311153
Offset: 1

Views

Author

Lothar Esser, Jun 03 2016

Keywords

Comments

The sequence is related to the existing sequence in which primes are appended so that primes result 2, 23, 2311, 231131, ... (see A240563). The current sequence cannot start with the first prime 2 because it could not be extended since any number > 2 and ending in 2 is a nonprime. So this sequence has to start with 3.
One could also consider analogous sequences starting with any prime greater than 3.
The sequence of primes appended at n-th term is 3, 5, 11, 31, 101, 271, 347, 631, 719, 829, 1031, 1123, 1259, 1801, 1907, 2557, 2591, 2851, 2897, 3301, 3467, 3853, 4157, 4789, 6917, 6991, 7127, 7369, 9767, 13879, 15791, 17239, 19541, 22447, 23663, 25309, 25577, 25873, 29873, 33301, 33713, 34543, 36389, 37159, 39821, 40597, 41453, 41479, 43997, ... - Michael De Vlieger, Jun 03 2016

Examples

			Start with 3 as the first term.
a(2) = 53, since the next prime after a(1) = 3 is 5; 5 prepended to 3 gives 53, another prime.
a(3) = 1153, since the next prime after that appended to a(2), i.e., 5, is 7, however 7 appended to a(2) = 753 = 3 * 251. The next prime 11, appended to a(2) gives us 1153, which is prime.
		

Crossrefs

Cf. A240563.

Programs

  • Mathematica
    a = {3}; Do[p = NextPrime@ a[[n - 1]]; While[! PrimeQ@ FromDigits@ Join[IntegerDigits@ p, Flatten@ Map[IntegerDigits, Reverse@ a]], p = NextPrime@ p]; AppendTo[a, p], {n, 2, 14}]; FoldList[FromDigits@ Join[IntegerDigits@ #2, IntegerDigits@ #1] &, a] (* Michael De Vlieger, Jun 03 2016 *)
  • Python
    from itertools import islice
    from sympy import isprime, nextprime
    def agen(): # generator of terms
        p = an = 3
        while True:
            yield an
            s = str(an)
            while not isprime(int(str(p) + s)): p = nextprime(p)
            an = int(str(p) + s)
    print(list(islice(agen(), 14))) # Michael S. Branicky, Oct 29 2022
  • Tcl
    #! /usr/bin/tclsh
    set prime_list_file list_prime_1000.dat ;
    proc PR_read_primes { fh } {
    global Prime Nprime;
      set idx 0;
      while { ![eof $fh] } {
        gets $fh line;
        foreach p $line {
          set Prime($idx) $p;
          incr idx;
        }
      }
      set Nprime $idx;
    }
    proc PR_is_prime { num } {
      set channel [open "| factor $num r"];
      fconfigure $channel -buffering none;
      set line [read $channel] ;
      #puts "$line [llength $line]";
      if { [llength $line] == 2 } {
        catch { close $channel}
        return 1;
      }
      return 0;
    }
    ### main
    if { ! [catch "open $prime_list_file r" fh ] } {
      PR_read_primes $fh;
      close $fh;
    } else {
        puts "Cannot open file $prime_list_file";
        exit 1
    }
    set t $Prime(1);
    set num_tested_primes 0;
    for { set idx 2 } { $idx < 1000 } { incr idx } {
      # Assemble
      # Simple tests
      set s $Prime($idx)$t;
      if { [PR_is_prime $s] } {
        set t $s;
        puts "$t prepended prime $Prime($idx) skipped $num_tested_primes";
        set num_tested_primes 0;
      } else {
         incr num_tested_primes;
      }
    }
    # The language is Tcl but it requires and external file with the first 1000 primes for convenience. It also uses UNIX program factor as external function to find out whether the number is a prime.