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.

This page as a plain text file.
%I A273802 #32 Dec 10 2023 17:43:18
%S A273802 3,53,1153,311153,101311153,271101311153,347271101311153,
%T A273802 631347271101311153,719631347271101311153,829719631347271101311153,
%U A273802 1031829719631347271101311153,11231031829719631347271101311153,125911231031829719631347271101311153,1801125911231031829719631347271101311153
%N A273802 Prime numbers formed by successively prepending prime numbers to 3.
%C A273802 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.
%C A273802 One could also consider analogous sequences starting with any prime greater than 3.
%C A273802 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
%H A273802 Michael S. Branicky, <a href="/A273802/b273802.txt">Table of n, a(n) for n = 1..181</a>
%e A273802 Start with 3 as the first term.
%e A273802 a(2) = 53, since the next prime after a(1) = 3 is 5; 5 prepended to 3 gives 53, another prime.
%e A273802 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.
%t A273802 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 *)
%o A273802 (Tcl)
%o A273802 #! /usr/bin/tclsh
%o A273802 set prime_list_file list_prime_1000.dat ;
%o A273802 proc PR_read_primes { fh } {
%o A273802 global Prime Nprime;
%o A273802   set idx 0;
%o A273802   while { ![eof $fh] } {
%o A273802     gets $fh line;
%o A273802     foreach p $line {
%o A273802       set Prime($idx) $p;
%o A273802       incr idx;
%o A273802     }
%o A273802   }
%o A273802   set Nprime $idx;
%o A273802 }
%o A273802 proc PR_is_prime { num } {
%o A273802   set channel [open "| factor $num r"];
%o A273802   fconfigure $channel -buffering none;
%o A273802   set line [read $channel] ;
%o A273802   #puts "$line [llength $line]";
%o A273802   if { [llength $line] == 2 } {
%o A273802     catch { close $channel}
%o A273802     return 1;
%o A273802   }
%o A273802   return 0;
%o A273802 }
%o A273802 ### main
%o A273802 if { ! [catch "open $prime_list_file r" fh ] } {
%o A273802   PR_read_primes $fh;
%o A273802   close $fh;
%o A273802 } else {
%o A273802     puts "Cannot open file $prime_list_file";
%o A273802     exit 1
%o A273802 }
%o A273802 set t $Prime(1);
%o A273802 set num_tested_primes 0;
%o A273802 for { set idx 2 } { $idx < 1000 } { incr idx } {
%o A273802   # Assemble
%o A273802   # Simple tests
%o A273802   set s $Prime($idx)$t;
%o A273802   if { [PR_is_prime $s] } {
%o A273802     set t $s;
%o A273802     puts "$t prepended prime $Prime($idx) skipped $num_tested_primes";
%o A273802     set num_tested_primes 0;
%o A273802   } else {
%o A273802      incr num_tested_primes;
%o A273802   }
%o A273802 }
%o A273802 # 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.
%o A273802 (Python)
%o A273802 from itertools import islice
%o A273802 from sympy import isprime, nextprime
%o A273802 def agen(): # generator of terms
%o A273802     p = an = 3
%o A273802     while True:
%o A273802         yield an
%o A273802         s = str(an)
%o A273802         while not isprime(int(str(p) + s)): p = nextprime(p)
%o A273802         an = int(str(p) + s)
%o A273802 print(list(islice(agen(), 14))) # _Michael S. Branicky_, Oct 29 2022
%Y A273802 Cf. A240563.
%K A273802 nonn,base
%O A273802 1,1
%A A273802 _Lothar Esser_, Jun 03 2016