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.
%I A241020 #24 Jul 21 2024 11:12:36 %S A241020 1,0,1,2,0,0,6,0,1,2,0,2,1,0,3,0,0,5,2,0,6,4,0,7,4,0,12,0,0,19,8,0,26, %T A241020 5,0,0,33,0,6,11,0,1,23,0,18,34,0,15,0,0,1,22,0,1,50,0,32,15,0,15,25, %U A241020 0,21,10,0,29,47,0,0,11,0,56,14,0,2,0,0,54,3 %N A241020 a(n) is the smallest j such that the n-digit number consisting of a 1 in position j and 7's in the other n-1 positions is a prime, or 0 if no such prime exists. %C A241020 Previous name: Let x(1)x(2)... x(n) denote the decimal expansion of a number p having an index j such that x(j) = 1 and x(i) = 7 for i <> j. The sequence lists the smallest index j such that p is prime, or 0 if no such prime exists. %C A241020 Except 0, the corresponding primes are 17, 0, 1777, 71777, 0, 0, 77777177, 0, 1777777777, 71777777777, 0, 7177777777777, 17777777777777, 0, 7717777777777777, 0, 0, 7777177777777777777, ... . %H A241020 Robert Israel, <a href="/A241020/b241020.txt">Table of n, a(n) for n = 2..4000</a> %F A241020 a(n) = 0 when 7*(n-1) + 1 mod 3 = 0. - _Michael S. Branicky_, Jun 02 2024 %p A241020 with(numtheory):nn:=80:T:=array(1..nn): %p A241020 for n from 2 to nn do: %p A241020 for i from 1 to n do: %p A241020 T[i]:=7: %p A241020 od: %p A241020 ii:=0: %p A241020 for j from 1 to n while(ii=0)do: %p A241020 T[j]:=1:s:=sum('T[i]*10^(n-i)', 'i'=1..n): %p A241020 if type(s,prime)=true %p A241020 then %p A241020 ii:=1: printf(`%d, `,j): %p A241020 else %p A241020 T[j]:=7: %p A241020 fi: %p A241020 od: %p A241020 if ii=0 %p A241020 then %p A241020 printf(`%d, `,0): %p A241020 else %p A241020 fi: %p A241020 od: %t A241020 Flatten[Position[IntegerDigits[#],1]&/@Table[Select[FromDigits/@Permutations[ Join[ {1},PadRight[ {},n,7]]],PrimeQ]/.{}->{0,0},{n,80}][[;;,1]]/.{}->0] (* _Harvey P. Dale_, Jul 21 2024 *) %o A241020 (Python) %o A241020 from sympy import isprime %o A241020 def a(n): %o A241020 if (1+7*(n-1))%3 == 0: %o A241020 return 0 %o A241020 base = (10**n-1)//9*7 %o A241020 for j in range(1, n+1): %o A241020 t = base - 6*10**(n-j) %o A241020 if isprime(t): %o A241020 return j %o A241020 return 0 %o A241020 print([a(n) for n in range(2, 81)]) # _Michael S. Branicky_, Jun 02 2024 %Y A241020 Cf. A241018, A241019. %K A241020 nonn,base %O A241020 2,4 %A A241020 _Michel Lagneau_, Apr 15 2014 %E A241020 Name simplified by _Michael S. Branicky_, Jun 02 2024