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.
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, 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, 0, 21, 10, 0, 29, 47, 0, 0, 11, 0, 56, 14, 0, 2, 0, 0, 54, 3
Offset: 2
Links
- Robert Israel, Table of n, a(n) for n = 2..4000
Programs
-
Maple
with(numtheory):nn:=80:T:=array(1..nn): for n from 2 to nn do: for i from 1 to n do: T[i]:=7: od: ii:=0: for j from 1 to n while(ii=0)do: T[j]:=1:s:=sum('T[i]*10^(n-i)', 'i'=1..n): if type(s,prime)=true then ii:=1: printf(`%d, `,j): else T[j]:=7: fi: od: if ii=0 then printf(`%d, `,0): else fi: od:
-
Mathematica
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 *)
-
Python
from sympy import isprime def a(n): if (1+7*(n-1))%3 == 0: return 0 base = (10**n-1)//9*7 for j in range(1, n+1): t = base - 6*10**(n-j) if isprime(t): return j return 0 print([a(n) for n in range(2, 81)]) # Michael S. Branicky, Jun 02 2024
Formula
a(n) = 0 when 7*(n-1) + 1 mod 3 = 0. - Michael S. Branicky, Jun 02 2024
Extensions
Name simplified by Michael S. Branicky, Jun 02 2024
Comments