OFFSET
1,2
FORMULA
To generate the sequence, start with the integers, A_0={1,2,3,4,5,...}. To generate A_{n+1} calculate x = A_n(n) + A_n(n+1). Replace the next instance of x in A_n (after A_n(n+1)) with A_n(n), A_n(n+1). The limit of this process gives the sequence.
EXAMPLE
A_0 = {1,2,3,4,5,...}.
A_0(0) + A_0(1) = 1 + 2 = 3, which is found after A_0(1), so A_1 = {1,2,1,2,4,5,...}.
A_1(1) + A_1(2) = 2 + 1 = 3, which is *not* found after A_1(2), so A_2 = A_1.
A_2(2) + A_2(3) = 1 + 2 = 3, A_3 = A_2.
A_3(3) + A_3(4) = 2 + 4 = 6, A_4 = {1,2,1,2,4,5,2,4,7,8,9,10,...}.
A_4(4) + A_4(5) = 4 + 5 = 9, A_5 = {1,2,1,2,4,5,2,4,7,8,4,5,10,...}.
MATHEMATICA
T = Range[100]; Do[s = T[[i]] + T[[i + 1]]; Do[If[T[[j]] == s, T = Join[ T[[;; j-1]], {T[[i]], T[[i+1]]}, T[[j+1 ;; ]]]; Break[]], {j, i+2, Length@ T}], {i, Length@T}]; T (* Giovanni Resta, Sep 20 2019 *)
PROG
(Kotlin)
fun generate(len: Int): List<Int> {
fun gen_inner(len: Int, level: Int): List<Int> {
if (level < 1) return (1..len).toList()
val prev = gen_inner(len, level - 1)
if (level == len) return prev.take(len)
val (a, b) = prev[level - 1] to prev[level]
return if (prev.drop(level + 1).contains(a+b)) {
prev.indexOfFirst { it == a+b }.let { idx ->
prev.take(idx) + a + b + prev.drop(idx + 1)
}
} else prev
}
return gen_inner(len, len)
}
(PARI)
a = vector(92, k, k);
for (n=1, #a-1, s=a[n]+a[n+1]; print1 (a[n] ", "); for (k=n+2, #a - 1, if (a[k]==s, a=concat([a[1..k-1], a[n..n+1], a[k+1..#a]]); break)))
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Matthew Malone, Aug 05 2019
STATUS
approved