cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A331898 The smallest prime number with exactly n circular loops in its decimal representation.

This page as a plain text file.
%I A331898 #42 Jun 12 2020 02:37:41
%S A331898 2,19,83,89,809,1889,8089,48889,88883,828889,688889,3888889,8868889,
%T A331898 28888889,88888883,288888889,808888889,6886888889,8688888889,
%U A331898 48888888889,188688888889,288888888889,888088888889,1888888888889,8888988888889,58888888888889,188880888888889
%N A331898 The smallest prime number with exactly n circular loops in its decimal representation.
%C A331898 Least prime p such that A064532(p) = n.
%C A331898 The digit 8 has two loops and the digits 0, 6 and 9 have one loop.
%H A331898 Giovanni Resta, <a href="/A331898/b331898.txt">Table of n, a(n) for n = 0..100</a>
%H A331898 Chris K. Caldwell and G. L. Honaker, Jr., <a href="https://primes.utm.edu/curios/page.php?curio_id=37446">Prime Curio for 19</a>
%e A331898 a(3) = 89 because 8 has two loops and 9 has one loop for a total of 3.
%t A331898 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 *)
%t A331898 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 *)
%o A331898 (PARI) \\ here b(n) is A064532.
%o A331898 b(n)={vecsum([if(d==8,2, d==0||d==6||d==9) | d<-digits(n)])}
%o A331898 a(n)={forprime(p=1, oo, if(b(p)==n, return(p)))} \\ _Andrew Howroyd_, Jan 31 2020
%Y A331898 Cf. A000040, A064532, A327820.
%K A331898 nonn,base
%O A331898 0,1
%A A331898 _Sara Mutter_, Jan 31 2020
%E A331898 a(13)-a(16) from _Andrew Howroyd_, Jan 31 2020
%E A331898 a(17)-a(19) from _Jinyuan Wang_, Feb 08 2020
%E A331898 a(20)-a(26) from _Giovanni Resta_, Feb 09 2020