# [seqfan] Re: A sequence and a few questions

M. F. Hasler seqfan at hasler.fr
Sun Jul 9 18:07:34 CEST 2023

```On Wed, Jul 5, 2023 at 10:08 PM Ali Sada vwrote:

> Start with a list of positive integers 1,2,3,4… Take each number in the
> list (m) in turn and repeat it m times. Place the repeated numbers in
> non-consecutive locations to the right of m and amend the list accordingly.

We start with 1,2,3,4,5,6,7,8,9,10…
> We repeat the 1 one time and put it after 2.
> 1,2,1,3,4,5,6,7,8…
> We repeat the 2 twice and place the new “copies” after the second 1 and
> the first 3
> 1,2,1,2,3,2,4,5,6,7,8….
>
And so on. We get:
>  1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 3, 5, 4, 5, 6, 5, 6, 4, 6, 5, 6,
> 7, 6, 7, 8, 7, 8, 6, 8, 7, 8…

I confirm, for the first 100 terms I get (PARI code at the end).
a = (1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 3, 5, 4, 5, 6, 5, 6, 4, 6, 5,
6, 7, 6, 7, 8, 7, 8, 6, 8, 7, 8, 9, 8, 9, 7, 9, 8, 9, 6, 9, 8, 9, 7, 9, 8,
9, 10, 9, 10, 8, 10, 9, 10, 7, 10, 11, 10, 11, 7, 11, 10, 11, 12, 11, 12,
10, 12, 11, 12, 13, 12, 13, 11, 13, 12, 13, 10, 13, 12, 13, 11, 13, 12, 13,
14, 13, 14, 12, 14, 13, 14, 11, 14, 13, 14, 12, 14, ...)

The position of the first occurrence of n = 1, 2, ... is
F = (1, 2, 5, 8, 11, 18, 25, 28, 35, 50, 59, 66, 73, 88, 115, 126, 129,
136, 151, 182, 211, 234, 249, 280, 315, 330, 337, 352, 383, 414, 465, 492,
507, 538, 601, 642, 665, 680, 711, 774, 835, 866, 889, 904, 935, 998, 1083,
1122, 1169, 1200, 1263, 1364, 1383, 1394, 1409, 1440, 1503, 1566, 1665,
1716, 1747, 1810, 1933, 1992, 2027, 2058, 2121, 2248, 2325, 2396, 2503,
2542, 2589, 2628, 2691, 2754, 2881, 2984, ...)

The position of the last  occurrence of n = 1, 2, ... is
L = (3, 6, 14, 21, 23, 42, 62, 53, 55, 122, 124, 118, 109, 116, 322, 295,
222, 199, 195, 232, 303, 326, 309, 367, 819, 653, 490, 449, 468, 482, 657,
645, 612, 610, 850, 1153, 885, 815, 803, 877, 1471, 1375, 1149, 1075, 1051,
1096, 1386, 1369, 1371, 1336, 1365, ...)

> 1.    Is this sequence suitable for the OEIS?

I think it's sufficiently nontrivial and "natural" (not contrived).
Maybe the only bit of possible "artificiality" could be that the number m
is duplicated m times for a total m+1 instances in the final sequence.
If me make the choice of m instances of m in the final sequence, we get
b = (1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 4, 6, 5, 6, 7, 6, 7, 5, 7,
6, 7, 8, 7, 8, 9, 8, 9, 7, 9, 8, 9, 10, 9, 10, 8, 10, 9, 10, 7, 10, 9, 10,
8, 10, 9, 10, 11, 10, 11, 9, 11, 10, 11, 8, 11, 12, 11, 12, 8, 12, 11, 12,
13, 12, 13, 11, 13, 12, 13, 14, 13, 14, 12, 14, 13, 14, 11, 14, 13, 14, 12,
14, 13, 14, 15, 14, 15, 13, 15, 14, 15, 12, 15, 14, 15, 13...)
But this isn't in OEIS, either - nor are respective indices of first & last
occurrence,
F = (1, 2, 3, 6, 9, 12, 19, 26, 29, 36, 51, 60, 67, 74, 89, 116, 127, 130,
137, 152, ...)
L = (1, 4, 7, 15, 22, 24, 43, 63, 54, 56, 123, 125, 119, 110, 117, 323,
296, 223, 200, ...)

2.    Is the definition above accurate?

I would change just a few details:

(a) not "a" but: ... *the* list of *the* positive integers 1,2,3,...

(b) instead of
"Take each number in the list (m) in turn and repeat it m times.
Place the repeated numbers..."
I would prefer:
"For each m = 1, 2, 3..., *insert*  m  *additional* copies of the number m
...

3.    Can we find a general formula?
>

probably possible, but not obvious to me.
The above results for the first and last position of "m" seem not in OEIS,
nor their first differences.

- Maximilian
(PARI)
a=List([1..99]) ; i = 1
{for( n = 1, 99, while ( a[i] != n, i++ ) ; for ( j = 1, n,
if ( i+2*j > #a, return([n,i,j]), list insert ( a, n, i + 2*j ))
)) }

\\% = [83, 3423, 79]

c=F=L=[1..99]*0; for ( n = 1, i+1, if( F[x=a[n]], L[x]=n, F[x]=n); c[x]++)
c = vecmax(c); print("ok up to index "i", m_max="c"\nF = "F[1..c]"\nL =
"L[1..c])

ok up to index 3423, m_max=82
F = [1, 2, 5, 8, 11, 18, 25, 28, 35, 50, 59, 66, 73, 88, 115, 126, 129,
136, 151, 182, 211, 234, 249, 280, 315, 330, 337, 352, 383, 414, 465, 492,
507, 538, 601, 642, 665, 680, 711, 774, 835, 866, 889, 904, 935, 998, 1083,
1122, 1169, 1200, 1263, 1364, 1383, 1394, 1409, 1440, 1503, 1566, 1665,
1716, 1747, 1810, 1933, 1992, 2027, 2058, 2121, 2248, 2325, 2396, 2503,
2542, 2589, 2628, 2691, 2754, 2881, 2984, 3047, 3142, 3205, 3332]
L = [3, 6, 14, 21, 23, 42, 62, 53, 55, 122, 124, 118, 109, 116, 322, 295,
222, 199, 195, 232, 303, 326, 309, 367, 819, 653, 490, 449, 468, 482, 657,
645, 612, 610, 850, 1153, 885, 815, 803, 877, 1471, 1375, 1149, 1075, 1051,
1096, 1386, 1369, 1371, 1336, 1365, 3395, 2675, 2019, 1714, 1633, 1668,
1698, 2003, 1984, 1927, 1934, 2510, 2495, 2336, 2265, 2261, 2487, 2565,
2596, 3415, 3407, 3130, 2972, 2952, 2930, 3122, 3419, 3328, 3421, 3401,
3424]
```

More information about the SeqFan mailing list