login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A273802 Prime numbers formed by successively prepending prime numbers to 3. 1

%I #32 Dec 10 2023 17:43:18

%S 3,53,1153,311153,101311153,271101311153,347271101311153,

%T 631347271101311153,719631347271101311153,829719631347271101311153,

%U 1031829719631347271101311153,11231031829719631347271101311153,125911231031829719631347271101311153,1801125911231031829719631347271101311153

%N Prime numbers formed by successively prepending prime numbers to 3.

%C 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 One could also consider analogous sequences starting with any prime greater than 3.

%C 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 Michael S. Branicky, <a href="/A273802/b273802.txt">Table of n, a(n) for n = 1..181</a>

%e Start with 3 as the first term.

%e a(2) = 53, since the next prime after a(1) = 3 is 5; 5 prepended to 3 gives 53, another prime.

%e 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 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 (Tcl)

%o #! /usr/bin/tclsh

%o set prime_list_file list_prime_1000.dat ;

%o proc PR_read_primes { fh } {

%o global Prime Nprime;

%o set idx 0;

%o while { ![eof $fh] } {

%o gets $fh line;

%o foreach p $line {

%o set Prime($idx) $p;

%o incr idx;

%o }

%o }

%o set Nprime $idx;

%o }

%o proc PR_is_prime { num } {

%o set channel [open "| factor $num r"];

%o fconfigure $channel -buffering none;

%o set line [read $channel] ;

%o #puts "$line [llength $line]";

%o if { [llength $line] == 2 } {

%o catch { close $channel}

%o return 1;

%o }

%o return 0;

%o }

%o ### main

%o if { ! [catch "open $prime_list_file r" fh ] } {

%o PR_read_primes $fh;

%o close $fh;

%o } else {

%o puts "Cannot open file $prime_list_file";

%o exit 1

%o }

%o set t $Prime(1);

%o set num_tested_primes 0;

%o for { set idx 2 } { $idx < 1000 } { incr idx } {

%o # Assemble

%o # Simple tests

%o set s $Prime($idx)$t;

%o if { [PR_is_prime $s] } {

%o set t $s;

%o puts "$t prepended prime $Prime($idx) skipped $num_tested_primes";

%o set num_tested_primes 0;

%o } else {

%o incr num_tested_primes;

%o }

%o }

%o # 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 (Python)

%o from itertools import islice

%o from sympy import isprime, nextprime

%o def agen(): # generator of terms

%o p = an = 3

%o while True:

%o yield an

%o s = str(an)

%o while not isprime(int(str(p) + s)): p = nextprime(p)

%o an = int(str(p) + s)

%o print(list(islice(agen(), 14))) # _Michael S. Branicky_, Oct 29 2022

%Y Cf. A240563.

%K nonn,base

%O 1,1

%A _Lothar Esser_, Jun 03 2016

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 11:35 EDT 2024. Contains 371912 sequences. (Running on oeis4.)