A273802 Prime numbers formed by successively prepending prime numbers to 3.
3, 53, 1153, 311153, 101311153, 271101311153, 347271101311153, 631347271101311153, 719631347271101311153, 829719631347271101311153, 1031829719631347271101311153, 11231031829719631347271101311153, 125911231031829719631347271101311153, 1801125911231031829719631347271101311153
Offset: 1
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.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..181
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.
Comments