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!)
A342101 Remove middle term and append, starting with [1, 2, 3]. 2
1, 2, 3, 1, 3, 1, 2, 1, 3, 1, 2, 3, 1, 1, 2, 1, 3, 1, 2, 3, 1, 3, 1, 2, 1, 1, 2, 3, 1, 1, 2, 1, 3, 1, 2, 3, 1, 3, 1, 2, 1, 3, 1, 2, 3, 1, 1, 2, 1, 1, 2, 3, 1, 3, 1, 2, 1, 1, 2, 3, 1, 1, 2, 1, 3, 1, 2, 3, 1, 3, 1, 2, 1, 3, 1, 2, 3, 1, 1, 2, 1, 3, 1, 2, 3, 1, 3 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
LINKS
EXAMPLE
Start with [1, 2, 3], take that sequence, remove the middle term, 2, and append to the original sequence, yielding [1, 2, 3, 1, 3]. Then repeat this process to give [1, 2, 3, 1, 3, 1, 2, 1, 3], and so on.
MAPLE
T:= proc(n) option remember; `if`(n=1, [$1..3][],
subsop(2^(n-2)+1=[][], [seq(T(i), i=1..n-1)])[])
end:
seq(T(n), n=1..8); # Alois P. Heinz, Apr 12 2021
MATHEMATICA
Nest[Join[#, Drop[#, {(Length[#] + 1)/2}]] &, Range[3], 6] (* Michael De Vlieger, May 01 2021 *)
PROG
(Kotlin)
fun A342101(iter: Int): List<Int> = removeMiddle(listOf(1, 2, 3), iter)
fun removeMiddle(initial: List<Int>, iter: Int): List<Int> {
if (iter < 2) return initial
val prev = removeMiddle(initial, iter-1)
return prev + prev.subList(0, (prev.size - 1) / 2) + prev.subList((prev.size + 1) /2, prev.size)
}
(Python)
def aupton(terms):
alst = [1, 2, 3]
while len(alst) < terms:
alst += alst[:len(alst)//2] + alst[(len(alst)+1)//2:]
return alst[:terms]
print(aupton(87)) # Michael S. Branicky, Mar 26 2021
(PARI) first(n) = { my(v = [1, 2, 3]); for(i = 1, logint(n-1, 2), cv = v[^(#v + 1)\2]; v = concat(v, cv) ); v } \\ David A. Corneth, Apr 14 2021
(PARI) \\ Also see links.
CROSSREFS
Cf. A000051.
Sequence in context: A134411 A126044 A342344 * A114899 A220906 A023678
KEYWORD
nonn
AUTHOR
Matthew Malone, Feb 28 2021
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 April 25 07:53 EDT 2024. Contains 371964 sequences. (Running on oeis4.)