The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A360504 Concatenate the ternary strings for 1,2,...,n-1, n, n-1, ..., 2,1. 3
1, 121, 121021, 1210111021, 12101112111021, 121011122012111021, 1210111220212012111021, 12101112202122212012111021, 1210111220212210022212012111021, 1210111220212210010110022212012111021, 1210111220212210010110210110022212012111021, 1210111220212210010110211010210110022212012111021 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
COMMENTS
If the terms are read as ternary strings and converted to base 10, we get A260853. For example, a(3) = 121021_3 = 439_10, which is A260853(3). This is a prime. What is the next prime term?
If the terms are read as decimal numbers, which of them are primes? a(3) = 121021_10 is a decimal prime, but what is the next one? It is a surprise that 121021 is a prime in both base 3 and base 10.
LINKS
EXAMPLE
To get a(3) we concatenate 1, 2, 10, 2, and 1, getting 121021.
MAPLE
t:= n-> (l-> parse(cat(seq(l[-i], i=1..nops(l)))))(convert(n, base, 3)):
a:= n-> parse(cat(map(t, [$1..n, n-i$i=1..n-1])[])):
seq(a(n), n=1..12); # Alois P. Heinz, Feb 17 2023
MATHEMATICA
Table[FromDigits[Flatten[Join[IntegerDigits[#, 3]&/@Range[n], IntegerDigits[#, 3]&/@ Range[ n-1, 1, -1]]]], {n, 20}] (* Harvey P. Dale, Oct 01 2023 *)
PROG
(Python)
from sympy.ntheory import digits
def a(n): return int("".join("".join(map(str, digits(k, 3)[1:])) for k in list(range(1, n+1))+list(range(n-1, 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(): # generator of terms
sf, sr = "", ""
for n in count(1):
sn = "".join(map(str, digits(n, 3)[1:]))
sf += sn
yield int(sf + sr)
sr = sn + sr
print(list(islice(agen(), 15))) # Michael S. Branicky, Feb 18 2023
CROSSREFS
This is the ternary analog of A173426.
Sequence in context: A202887 A195275 A082489 * A028463 A013749 A178192
KEYWORD
nonn,base
AUTHOR
N. J. A. Sloane, Feb 17 2023
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified June 17 00:51 EDT 2024. Contains 373432 sequences. (Running on oeis4.)