OFFSET
2,1
COMMENTS
If n is not divisible by 3, a(n) is the least prime with sum of digits n.
If n > 3 is divisible by 3 but not by 9, a(n) = 3*p where p is prime.
If n is divisible by 9, a(n) is divisible by 9.
Conjecture: a(n) == 9 (mod 10) for all n > 25.
Conjecture: all terms are zeroless. - Chai Wah Wu, Mar 30 2023
LINKS
Chai Wah Wu, Table of n, a(n) for n = 2..304
EXAMPLE
a(4) = 13 because 13 is the first prime whose sum of digits is 4.
a(6) = 6 because 6 = 3*2 where 2 is prime and 6 has sum of digits 6.
MAPLE
f106843:= proc(t) local w; w:= padic:-ordp(t, 3); isprime(t/3^w) or t/3^w = 1 end proc;
V:= Array(2..60): count:= 0:
for x from 2 while count < 59 do
if f106843(x) then
s:= convert(convert(x, base, 10), `+`);
if s <= 60 and V[s] = 0 then V[s]:= x; count:= count+1; fi
fi
od:
convert(V, list);
PROG
(Python)
from itertools import count
from sympy import isprime
from sympy.utilities.iterables import multiset_permutations, partitions
from gmpy2 import digits
def A361831(n):
for m in count((n+8)//9):
c = (t:=10**m)
for a, b in partitions(n, m=m, k=9, size=True):
b[0] = (m-a)
for s in multiset_permutations(b):
if (lambda n:isprime(n) or n==1)(int('0'+digits(k:=int('0'+''.join(str(d) for d in s)), 3).rstrip('0'), 3)):
c = min(c, k)
if c < t:
return c # Chai Wah Wu, Mar 30-31 2023
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Robert Israel, Mar 26 2023
STATUS
approved