login
Smallest prime with n holes in its decimal digits.
3

%I #50 Sep 27 2019 15:46:56

%S 2,19,83,89,809,1889,4889,46889,48889,468889,688889,3888889,4888889,

%T 28888889,88884889,288888889,808888889,4488888889,8688888889,

%U 48808888889,48888888889,288888888889,888088888889,1888888888889,4888888888889,48808888888889,88848888888889

%N Smallest prime with n holes in its decimal digits.

%C Smallest prime p such that A064692(p) = n. Also record-holders in A327462. - _Felix Fröhlich_, Sep 27 2019

%C The sequence is not monotonically increasing: a(32) > a(33). - _Giovanni Resta_, Sep 27 2019

%H Giovanni Resta, <a href="/A327820/b327820.txt">Table of n, a(n) for n = 0..100</a>

%t s[0] = {1,2,3,5,7}; s[1] = {0,4,6,9}; s[2] = {8}; m[{sn_, t_}] := Union[Sort /@ Tuples[s[sn], {t}]]; f[nd_, nh_] := Block[{v, pa = Tally /@ IntegerPartitions[ nh, {nd}, {0, 1, 2}], bst = Infinity}, Do[v = Flatten /@ Tuples[m /@ p]; Do[z = Select[ FromDigits /@ Select[ Permutations[e], First[#] > 0 && OddQ[Last[#]] &], PrimeQ]; bst = Min[bst, {z}], {e, v}], {p, pa}]; bst]; a[0]=2; a[n_] := Block[{nd = Ceiling[(n + 1)/2], b}, While[! IntegerQ@ (b = f[nd, n]), nd++]; b]; a /@ Range[0, 30] (* _Giovanni Resta_, Sep 27 2019 *)

%o (PARI) count_holes(n) = my(d=digits(n), i=0); for(k=1, #d, if(d[k]==0 || d[k]==4 || d[k]==6 || d[k]==9, i++, if(d[k]==8, i+=2))); i

%o a(n) = forprime(p=1, , if(count_holes(p)==n, return(p))) \\ _Felix Fröhlich_, Sep 27 2019

%Y Cf. A064692, A249572, A250256, A327462.

%K nonn,base

%O 0,1

%A _Andrew Heathwaite_, Sep 26 2019

%E a(7) corrected and more terms added by _Felix Fröhlich_, Sep 27 2019

%E More terms from _Giovanni Resta_, Sep 27 2019