login
a(n) = smallest value of k such that the concatenation 1,n,n^2,..., n^(k-1),n^k,n^(k-1),...n^2,n,1 is a prime.
1

%I #11 Mar 20 2015 19:04:09

%S 9,2,1,12,1,2

%N a(n) = smallest value of k such that the concatenation 1,n,n^2,..., n^(k-1),n^k,n^(k-1),...n^2,n,1 is a prime.

%C Terms from _Robert G. Wilson v_.

%e a(1) = 9 as 1 (19 times) = (10^19-1)/9 is the smallest prime of this form with an odd number of 1's.

%e a(2) = 2 as 12421 is a prime.

%t Do[k = 0; While[a = Table[n^i, {i, 0, k}]; b = ToExpression[ StringJoin[ ToString /@ Join[a, Drop[ Reverse[a], 1]]]]; !PrimeQ[b], k++ ]; Print[k], {n, 1, 10} ] (* _Robert G. Wilson v_ *)

%Y See A069566 for another version.

%K more,nonn,base

%O 1,1

%A _Ray Chandler_ and _N. J. A. Sloane_, Apr 08 2014