login
A361831
a(n) is the first member of A106843 with sum of digits n.
1
2, 3, 13, 5, 6, 7, 17, 9, 19, 29, 39, 67, 59, 69, 79, 89, 99, 199, 389, 489, 499, 599, 699, 997, 1889, 999, 1999, 2999, 4989, 4999, 6899, 6999, 17989, 8999, 18999, 29989, 39989, 48999, 49999, 59999, 69999, 79999, 98999, 198999, 199999, 389999, 589989, 598999, 599999, 798999, 799999, 989999
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
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
Sequence in context: A067182 A342667 A191000 * A085402 A085400 A067523
KEYWORD
nonn,base
AUTHOR
Robert Israel, Mar 26 2023
STATUS
approved