A241018 a(n) is the smallest j such that the n-digit number consisting of a 1 in position j and 9's in the other n-1 positions is a prime, or 0 if no such prime exists.
1, 1, 1, 5, 1, 7, 1, 0, 2, 6, 3, 3, 11, 2, 14, 4, 0, 4, 6, 0, 4, 20, 6, 7, 18, 1, 1, 23, 8, 8, 23, 7, 0, 0, 0, 26, 33, 0, 11, 8, 5, 8, 13, 12, 44, 2, 2, 0, 11, 31, 17, 39, 1, 51, 5, 7, 4, 29, 9, 16, 0, 0, 26, 14, 26, 10, 13, 0, 0, 34, 40, 0, 15, 3, 14, 32, 0
Offset: 2
Links
- Robert Israel, Table of n, a(n) for n = 2..4033
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]:=9: 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]:=9: fi: od: if ii=0 then printf(`%d, `,0): else fi: od:
-
Mathematica
Table[With[{w = ConstantArray[9, n]}, SelectFirst[Range@ n, PrimeQ@ FromDigits@ ReplacePart[w, # -> 1] &]] /. m_ /; MissingQ@ m -> 0, {n, 2, 78}] (* Michael De Vlieger, Sep 13 2017 *)
-
Python
from sympy import isprime def a(n): base = (10**n-1) for j in range(1, n+1): t = base - 8*10**(n-j) if isprime(t): return j return 0 print([a(n) for n in range(2, 78)]) # Michael S. Branicky, Jun 02 2024
Extensions
Name simplified by Jon E. Schoenfield, Sep 13 2017
Comments