login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Concatenate the ternary strings for 1,2,...,n.
10

%I #40 Apr 19 2023 11:31:44

%S 1,12,1210,121011,12101112,1210111220,121011122021,12101112202122,

%T 12101112202122100,12101112202122100101,12101112202122100101102,

%U 12101112202122100101102110,12101112202122100101102110111,12101112202122100101102110111112,12101112202122100101102110111112120

%N Concatenate the ternary strings for 1,2,...,n.

%C If the terms are read as ternary strings and converted to base 10, we get A048435. For example, a(2) = 12_3 = 5_10, which is A048435(2). This is a prime, and gives the first term of A360503.

%C If the terms are read as decimal numbers, which of them are primes? 12101112202122100101102110111, for example, is not a prime, since it is 37*327057086543840543273030003.

%C When read as decimal numbers, the first prime is a(7315), with 56003 digits. - _Michael S. Branicky_, Apr 18 2023

%H Winston de Greef, <a href="/A360502/b360502.txt">Table of n, a(n) for n = 1..222</a>

%H <a href="/index/Mo#MWP">Index entries for sequences related to Most Wanted Primes video</a>

%e a(4): concatenate 1, 2, 10, 11, getting 121011.

%p a:= proc(n) option remember; `if`(n=0, 0, (l-> parse(cat(

%p a(n-1), seq(l[-i], i=1..nops(l)))))(convert(n, base, 3)))

%p end:

%p seq(a(n), n=1..15); # _Alois P. Heinz_, Feb 17 2023

%t nn = 15; s = IntegerDigits[Range[nn], 3]; Array[FromDigits[Join @@ s[[1 ;; #]]] &, nn] (* _Michael De Vlieger_, Apr 19 2023 *)

%o (Python)

%o from sympy.ntheory import digits

%o def a(n): return int("".join("".join(map(str, digits(k, 3)[1:])) for k in range(1, n+1)))

%o print([a(n) for n in range(1, 16)]) # _Michael S. Branicky_, Feb 18 2023

%o (Python) # faster version for initial segment of sequence

%o from sympy.ntheory import digits

%o from itertools import count, islice

%o def agen(s=""): yield from (int(s:=s+"".join(map(str, digits(n, 3)[1:]))) for n in count(1))

%o print(list(islice(agen(), 15))) # _Michael S. Branicky_, Feb 18 2023

%Y Cf. A007089, A036954, A360503, A360504.

%Y This is the ternary analog of A007908.

%K nonn,base

%O 1,2

%A _N. J. A. Sloane_, Feb 16 2023