A360505 Concatenate the ternary strings for n, n-1, n-2, ..., 2, 1.
1, 21, 1021, 111021, 12111021, 2012111021, 212012111021, 22212012111021, 10022212012111021, 10110022212012111021, 10210110022212012111021, 11010210110022212012111021, 11111010210110022212012111021, 11211111010210110022212012111021, 12011211111010210110022212012111021
Offset: 1
Programs
-
Mathematica
a[n_] := FromDigits @ Flatten @ IntegerDigits[Range[n, 1, -1], 3]; Array[a, 15] (* Amiram Eldar, Feb 18 2023 *)
-
PARI
a(n) = strjoin(concat([digits(k, 3) | k <- Vecrev([1..n])])) \\ Rémy Sigrist, Feb 18 2023
-
Python
from sympy.ntheory import digits def a(n): return int("".join("".join(map(str, digits(k, 3)[1:])) for k in range(n, 0, -1))) print([a(n) for n in range(1, 16)]) # Michael S. Branicky, Feb 18 2023
-
Python
# faster version for initial segment of sequence from sympy.ntheory import digits from itertools import count, islice def agen(s=""): yield from (int(s:="".join(map(str, digits(n, 3)[1:]))+s) for n in count(1)) print(list(islice(agen(), 15))) # Michael S. Branicky, Feb 18 2023
Comments