cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A360968 Permutation of the positive integers derived through a process of self-reference and self-editing. a(1) = 1. Other terms generated as described in Comments.

Original entry on oeis.org

1, 3, 2, 7, 4, 13, 5, 12, 22, 15, 23, 8, 6, 36, 10, 31, 40, 26, 25, 56, 16, 9, 11, 55, 19, 18, 67, 54, 28, 86, 21, 48, 42, 45, 90, 14, 20, 37, 106, 17, 95, 33, 71, 130, 34, 27, 41, 32, 91, 47, 141, 66, 73, 29, 24, 38, 94, 164, 76, 155, 57, 133, 193, 98, 92
Offset: 1

Views

Author

Carl R. White, Feb 27 2023

Keywords

Comments

Start with all terms set to the nominal value a(n) = n.
Mark all a(n), n > 1 as "unedited", and set a pointer p = 1.
For each unedited a(n), in increasing order of n, let q = n + a(p). Look at a(q). If a(q) has previously been edited, set a(n) = a(q); otherwise, set a(n) = q. In either case, then set a(q) = n. Mark both a(n) and a(q) as "edited". Increase p by 1 and move to the next unedited a(n), etc.
Note that once the process reaches any particular unedited n, sequence terms a(1) to a(n-1) will not be edited further by the generation process and are thus fixed. Terms of the sequence for entries greater than n may have been edited, but are "in flux" and may change again until n reaches them. p necessarily lags behind n, and so any a(p) is always well fixed by the time it is needed.
In many cases the generation process merely swaps two values relative to the positive integers, but since some edited terms could be re-edited, this will cause cycles to occur.
The positions of integers in this sequence would appear to be very hard to predict without actually generating the sequence.

Examples

			When n = 2, p = 1, so q := n+a(p) = 2+a(1) = 2+1 = 3. a(3) is "unedited" so a(n) = q and a(q) = n, i.e., set a(2) = 3 and a(3) = 2.
Since a(3) was edited by this, we continue at a(4), increasing p to 2.
Now, q := n+a(p) = 4+a(2) = 4+3 = 7. a(7) is unedited, so apply a(n) = q and a(q) = n again. i.e., set a(4) = 7 and a(7) = 4
a(5) was not edited previously, so we continue there, increasing p to 3.
Next, q := n+a(p) = 5 + a(3) = 5 + 2 = 7. a(7) is a previously edited term, so rather than use a(7)'s nominal value of 7, we instead use its currently held value of 4. I.e., a(n) = a(q) and, as always, a(q) = n. Thus we set a(5) = 4 and a(7) = 5. This must be done in the right order, lest both a(n) and a(q) be set to the same value (5 in this case).
At this point, note that while 2 and 3 are swapped relative to the positive integers, 4, 5, and 7 form a 3-cycle through their respective indices.
Continuing: a(6) is not yet edited, so n := 6 and p increases to 4. a(p) = 7, so we look to a(6+7) = a(13), an unedited term, so set a(6) = 13 and a(13) = 6, etc.
It so happens that a(13) is not edited again and remains 6, but in general it is theoretically possible that an edited term a(k) may be re-edited as long as n < k.
		

Crossrefs

Inspired loosely by A005185.
Cf. A236854, which is also self-altering in generation.

Programs

  • Python
    def A360968_list(maxn):
        B,C,p,n = [1],[],1,1
        while n < maxn:
            for i in range(2*n): B.append(0)
            n = B.index(0)+1
            q = n + B[p-1]
            if B[q-1] < 1: B[n-1] = q
            else: B[n-1] = B[q-1]
            B[q-1] = n
            p += 1
        for i in range(0,len(B)):
            if B[i]>0 and i+1 <= maxn:
                C.append(B[i])
        return C # John Tyler Rascoe, Mar 04 2023