OFFSET
1,1
COMMENTS
a(n) is either 10*n+1, 100*n+11 or 1000*n+111, because at least one of these is divisible by 3. - Robert Israel, Nov 01 2022
Actually: exactly one of these is divisible by 3. Almost all terms are a(n) = 10n + 1: this is the case for about (k-1)/k of the terms up to 10^k (i.e., 69% ~ 2/3 up to 10^3, 76% = 3/4 up to 10^4, 80% = 4/5 up to 10^5, 83% = 5/6 up to 10^6). - M. F. Hasler, Nov 03 2022
MAPLE
f:= proc(n) local x;
x:= n;
do
x:= 10*x+1;
if not isprime(x) then return x fi;
od
end proc:
map(f, [$1..100]); # Robert Israel, Nov 01 2022
MATHEMATICA
a[n_] := NestWhile[10*# + 1 &, 10*n + 1, ! CompositeQ[#] &]; Array[a, 54] (* Amiram Eldar, Nov 01 2022 *)
PROG
(Python)
from sympy import isprime
def A358154(n):
t = str(n)+'1'
while isprime(int(t)):t=t+'1'
return int(t)
print([A358154(i) for i in range(1, 100)])
(PARI) a(n) = my(d=digits(n), m); if (!isprime(n), d = concat(d, 1)); while(isprime(m=fromdigits(d)), d=concat(d, 1)); m; \\ Michel Marcus, Nov 01 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Gleb Ivanov, Nov 01 2022
STATUS
approved