[seqfan] Nice nontrivial integer sequence

M. F. Hasler seqfan at hasler.fr
Thu Mar 2 01:02:29 CET 2023


Hello SeqFans,
(sorry for the duplicate for those who are also on math-fun)

Today I found a nice idea on reddit, which I propose as
oeis.org/draft/A360447:

The idea is to insert all integers n = 1, 2, 3, ... in a list, between the
pair of consecutive elements whose sum equals n and whose absolute
difference is the smallest possible,
or at the end of the list of there's no such pair.

For n = 1 and n = 2, there is no pair in the sequence that sums to n, so
both of these are appended to the list, which then is [1, 2].
Now n = 3 is the sum of 1 & 2 so it is inserted between these two, the list
becomes [1, 3, 2]
Similarly, n = 4 is inserted between 1 & 3 and n = 5 is inserted between 3
& 2, to get [1, 4, 3, 5, 2].
Now n = 6 isn't the sum of any two adjacent terms, so it is appended: [1,
4, 3, 5, 2, 6].
Then n = 7 is the sum of 4+3 as well as 5+2, one has to compare the
differences |4-3| and |5-2| to find that it must be inserted between 4 and
3. And so on.

I wonder whether this is a permutation of the positive integers, i.e., any
n will eventually reach its final position in the sequence.
This is the case when it is no longer preceded by a pair of consecutive
terms with a sum larger than the current length of the sequence. It appears
that sufficiently many terms are not equal to a sum of a consecutive pair
and therefore appended to the end of the sequence, so that any n reaches a
stable position, sooner or later.

But I have absolutely no proof for this, and I don't even know at which
position the number 2 will eventually remain:
It's at position 106 when we've got 13 terms for sure (requiring 3185 terms
to be computed), at position 176 when we've got 14 good terms (using more
than 12K terms) and at position 234 when we've got 15 good terms (using
about 28K terms),
(1, 4, 11, 29, 47, 18, 61, 165, 434, 703, 1675, 972, 2213, 10093, 17973,
...)

Although the number 2 moves forward 60 more places each time I get one more
term for sure, I don't give up hope that it might eventually become
"stabilized"...
(BTW, the whole group (3, 8, 13, 5, 2, 6) moves away together, so all of
them will be "stabilized" at once (if they are) ; the number 10 also occurs
about 15 indices earlier, and 7 roughly half way there (around index 120
when they are around position 240).)

Can someone try to compute their final indices or get some estimate, maybe
proving that they (and/or any n) will reach its final destination sooner
or later?
Or find a more efficient way to compute just a few more terms? (I put
"hard,more" in the draft because 15 terms already take 30sec/1min and the
time seems to increase by a factor 4-5 for each new term. But I'd be glad
if there's a much better algorithm and it isn't hard after all.)

Thanks,

- Maximilian


More information about the SeqFan mailing list