login
Primes consisting of a single 1 and at least one copy of some other digit.
1

%I #26 Sep 23 2019 11:55:44

%S 13,17,19,31,41,61,71,199,313,331,661,881,919,991,1777,1999,2221,3313,

%T 3331,4441,6661,7177,7717,9199,31333,33331,71777,99991,199999,313333,

%U 331333,333331,991999,999199,3331333,3333133,3333313,3333331,9999991,19999999

%N Primes consisting of a single 1 and at least one copy of some other digit.

%C The second Mathematica program below is more complicated than the first but is more efficient. It takes advantage of the observation that any number with a single digit one and one or more copies of another digit from among 2, 4, 5, 6, or 8 can only be prime if the one is the last (least significant) digit. Thus, there is no need to generate or test any permutations of such a number. This means that the program generates and tests only 37.5% as many candidate numbers as the first Mathematica program below. On my laptop computer, in 2019, the first Mathematica program took about 8.2 seconds to compute all terms containing up to 200 digits, whereas the second Mathematica program only took about 6.4 seconds to do the same. - _Harvey P. Dale_, Sep 20 2019

%C A further improvement could be made by not testing any permutations of one together with 2, 5, 8, 11, etc. copies of seven, since any such number will have a digital sum of a multiple of three and thus cannot be prime. - _Harvey P. Dale_, Sep 23 2019

%H Harvey P. Dale, <a href="/A325934/b325934.txt">Table of n, a(n) for n = 1..1000</a>

%t Select[Flatten[Table[FromDigits/@Permutations[PadRight[{1},n,k]],{n,10},{k,Range[2,9]}]],PrimeQ]//Union

%t Module[{nn=10,c1,c2},c1=Select[Table[FromDigits[PadLeft[{1},n,k]],{k,{2,4,5,6,8}},{n,2,nn}]//Flatten,PrimeQ];c2=Select[FromDigits/@ Flatten[ Permutations/@Flatten[Table[PadLeft[{1},n,k],{k,{3,7,9}},{n,2,nn}],1],1],PrimeQ];Sort[Flatten[Join[{c1,c2}]]]] (* _Harvey P. Dale_, Sep 20 2019 *)

%o (PARI) lista(nn) = {forprime(p=1, nn, my(d = digits(p)); if ((#Set(d) == 2) && (#select(x->(x==1), d) == 1), print1(p, ", ")););} \\ _Michel Marcus_, Sep 11 2019

%Y Subsequence of A208270. Subsequence of A235154.

%K nonn,base

%O 1,1

%A _Harvey P. Dale_, Sep 09 2019