

A113030


Largest prime arising that can be formed by stringing together the decimal expansions of some or all of the first n numbers in some order.


0



2, 31, 4231, 5431, 65423, 7652413, 8765423, 98765431, 10987653421, 111098765423, 12111098765413, 13121110987654231, 141312111098765213, 15141312111098763241, 16151413121110987654213, 171615141312111098764523
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

2,1


LINKS

Table of n, a(n) for n=2..17.


EXAMPLE

a(3) = 31 as 321 or any other three digit permutation is not a prime and 23 < 31. Any permutation of all or a few of the first five numbers 1,2,3,4,5,gives the largest prime 5431. Hence a(5) = 5431.


MATHEMATICA

for 4<n<20 (* first do *) Needs["DiscreteMath`Combinatorica`"] (* then *) f[n_] := Block[{a = Flatten@IntegerDigits@Range[n, 6, 1], b = Flatten[ Permutations /@ Flatten[ Table[ KSubsets[ Range@5, i], {i, 5}], 1], 1], t = {}}, Do[AppendTo[t, Join[a, b[[k]] ]], {k, 325}]; Max@Select[FromDigits /@ t, PrimeQ[ # ] &]]; Table[ f[n], {n, 5, 18}] (* Robert G. Wilson v *)


CROSSREFS

Sequence in context: A239332 A244441 A004072 * A247873 A281901 A018802
Adjacent sequences: A113027 A113028 A113029 * A113031 A113032 A113033


KEYWORD

base,nonn


AUTHOR

Amarnath Murthy, Jan 03 2006


EXTENSIONS

a(7)a(18) from Robert G. Wilson v, Jan 11 2006


STATUS

approved



