OFFSET
2,2
COMMENTS
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) = 3 for i <> j. The sequence lists the smallest index j such that p is prime, or 0 if no such prime exists.
Except 0, the corresponding primes are 13, 313, 3313, 31333, 313333, 3331333, 31333333, 333331333, 3333133333, 33331333333, 333313333333, 0, 33133333333333, ... .
LINKS
Robert Israel, Table of n, a(n) for n = 2..4001
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]:=3:
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]:=3:
fi:
od:
if ii=0
then
printf(`%d, `, 0):
else
fi:
od:
PROG
(Python)
from sympy import isprime
def a(n):
base = (10**n-1)//9*3
for j in range(1, n+1):
t = base - 2*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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Michel Lagneau, Apr 15 2014
EXTENSIONS
Name simplified and offset corrected by Michael S. Branicky, Jun 02 2024
STATUS
approved