%I #39 Feb 26 2023 17:17:39
%S 2,3,4,6,9,10,16,40,104,8840
%N Numbers n such that the base-n number formed by concatenating the base-n numbers 1 2 ... n-1 n n-1 ... 2 1 is prime.
%C n = 8840 only corresponds to a probable prime (with 69770 decimal digits).
%C The concatenation (in base n) of the base-n numbers 1 2 3 ... k-1 k k-1 ... 3 2 1 is a square for k<n, so the case k=n, the subject of this sequence, is the first time a prime is possible.
%C Sequence A260852 lists the actual primes, A260852(k) = A260851(a(k)). - _M. F. Hasler_, Aug 02 2015
%H D. Broadhurst, <a href="https://listserv.nodak.edu/cgi-bin/wa.exe?A2=NMBRTHRY;af419558.1508">Primes from concatenation: results and heuristics</a>, NmbrThry List, August 1, 2015
%e For n = 2 we get the binary number 1 10 1 = 1101 = 13 (in decimal).
%e For n = 10 we get (as David Broadhurst remarks) the "memorable" decimal prime 12345678910987654321.
%e For n = 16 the prime is the hexadecimal number 123456789abcdef10fedcba987654321.
%t Select[Range[2, 120], PrimeQ@ Total[Times @@@ Transpose[{(Function[p, Power[#, p]] /@ Reverse@ Delete[Range[0, 2 # - 1], # + 1]), Flatten@ {Range[#], Reverse@ Range[# - 1]}}]] &] (* _Michael De Vlieger_, Aug 02 2015 *)
%t bnpQ[n_]:=PrimeQ[FromDigits[Flatten[Join[IntegerDigits[#,n]&/@Range[n], IntegerDigits[ #,n]&/@Reverse[Range[n-1]]]],n]]; Select[Range[2,110],bnpQ] (* _Harvey P. Dale_, Feb 26 2023 *)
%o (Python)
%o from gmpy2 import is_prime
%o def intbase(dlist,b=10): # convert list of digits in base b to integer
%o y = 0
%o for d in dlist:
%o y = y*b + d
%o return y
%o A260343_list = [n for n in range(2,500) if is_prime(intbase(list(range(1,n))+[1,0]+list(range(n-1,0,-1)), n))] # _Chai Wah Wu_, Aug 01 2015
%o (PARI) for(b=2,9e9,ispseudoprime(p=(1+b*c=(b^b-1)\(b-1))*(c-b+1)-1)&&print1(b", ")); \\ D. Broadhurst and _M. F. Hasler_, Aug 02 2015
%Y For n=2 see A173427, for n=10 see A173426.
%Y For n=3 through n=16 see A260853 - A260866.
%K nonn,base,more
%O 1,1
%A _N. J. A. Sloane_, Aug 01 2015
|