login
A331898
The smallest prime number with exactly n circular loops in its decimal representation.
3
2, 19, 83, 89, 809, 1889, 8089, 48889, 88883, 828889, 688889, 3888889, 8868889, 28888889, 88888883, 288888889, 808888889, 6886888889, 8688888889, 48888888889, 188688888889, 288888888889, 888088888889, 1888888888889, 8888988888889, 58888888888889, 188880888888889
OFFSET
0,1
COMMENTS
Least prime p such that A064532(p) = n.
The digit 8 has two loops and the digits 0, 6 and 9 have one loop.
LINKS
Chris K. Caldwell and G. L. Honaker, Jr., Prime Curio for 19
EXAMPLE
a(3) = 89 because 8 has two loops and 9 has one loop for a total of 3.
MATHEMATICA
Block[{s = Range[0, 15]}, Sort[#][[All, -1]] &@ Reap[Do[If[! FreeQ[s, #2], Sow[{#2, #1}]; s = DeleteCases[s, #2]] & @@ {#, Total[{0, 0, 0, 0, 0, 1, 0, 2, 1, 1} DigitCount[#]]} &@ Prime@ i, {i, 3*10^5}]][[-1, -1]]] (* Michael De Vlieger, Feb 08 2020 *)
s[0]={1, 2, 3, 4, 5, 7}; s[1]={0, 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, Feb 09 2020 *)
PROG
(PARI) \\ here b(n) is A064532.
b(n)={vecsum([if(d==8, 2, d==0||d==6||d==9) | d<-digits(n)])}
a(n)={forprime(p=1, oo, if(b(p)==n, return(p)))} \\ Andrew Howroyd, Jan 31 2020
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Sara Mutter, Jan 31 2020
EXTENSIONS
a(13)-a(16) from Andrew Howroyd, Jan 31 2020
a(17)-a(19) from Jinyuan Wang, Feb 08 2020
a(20)-a(26) from Giovanni Resta, Feb 09 2020
STATUS
approved