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.

Previous Showing 11-13 of 13 results.

A257729 Permutation of natural numbers: a(1)=1; a(prime(n)) = oddprime(a(n)), a(composite(n)) = not_an_oddprime(1+a(n)).

Original entry on oeis.org

1, 3, 7, 2, 19, 6, 5, 12, 4, 28, 71, 10, 17, 9, 20, 8, 13, 40, 41, 95, 16, 26, 11, 15, 30, 14, 21, 56, 109, 57, 359, 125, 25, 38, 18, 24, 31, 44, 22, 32, 61, 77, 29, 143, 78, 445, 73, 162, 36, 54, 27, 35, 23, 45, 62, 33, 46, 84, 43, 104, 179, 42, 185, 105, 545, 98, 181, 208, 51, 75, 503, 39, 59, 50, 34, 63, 85, 48, 103, 64, 114, 60, 37
Offset: 1

Views

Author

Antti Karttunen, May 09 2015

Keywords

Comments

Here composite(n) = n-th composite = A002808(n), prime(n) = n-th prime = A000040(n), oddprime(n) = n-th odd prime = A065091(n) = A000040(n+1), not_an_oddprime(n) = n-th natural number which is not an odd prime = A065090(n).

Examples

			As an initial value we have a(1) = 1.
2 is the first prime (= A000040(1)), so we take the a(1)-th odd prime, A065091(1) = 3, thus a(2) = 3.
3 is the second prime, thus we take a(2)-th odd prime, A065091(3) = 7, thus a(3) = 7.
4 is the first composite, thus we take a(1)-th number larger than one which is not an odd prime, and that is A065090(1+1) = 2, thus a(4) = 2.
5 is the third prime, thus we take a(3)-th odd prime, which is A065091(7) = 19, thus a(5) = 19.
		

Crossrefs

Inverse: A257730.
Related or similar permutations: A257728, A246377, A257731, A257802, A236854.

Programs

Formula

a(1) = 1; if A010051(n) = 1 [i.e., if n is a prime], then a(n) = A065091(a(A000720(n))), otherwise a(n) = A065090(1+a(A065855(n))).
As a composition of other permutations:
a(n) = A257728(A246377(n)).
a(n) = A257802(A257731(n)).

A245812 Self-inverse permutation of natural numbers: a(0) = 0, a(1) = 1, and for n > 1, if A065620(n) < 0, a(n) = A065621(1+a(-(A065620(n)))), otherwise a(n) = A048724(a(A065620(n)-1)).

Original entry on oeis.org

0, 1, 3, 2, 6, 7, 4, 5, 15, 14, 13, 12, 11, 10, 9, 8, 24, 25, 26, 27, 28, 29, 30, 31, 16, 17, 18, 19, 20, 21, 22, 23, 57, 56, 59, 58, 61, 60, 63, 62, 49, 48, 51, 50, 53, 52, 55, 54, 41, 40, 43, 42, 45, 44, 47, 46, 33, 32, 35, 34, 37, 36, 39, 38, 106, 107, 104, 105, 110, 111, 108, 109, 98, 99, 96, 97, 102, 103, 100
Offset: 0

Views

Author

Antti Karttunen, Aug 20 2014

Keywords

Comments

This is an instance of entanglement permutation, where complementary pair A048724/A065621 is entangled with the same pair in the opposite order: A065621/A048724, with a(1) set to 1.
Note how this is A193231-conjugate of A054429.

Crossrefs

Programs

  • PARI
    a048724(n) = bitxor(n, 2*n);
    a065620(n) = if(n<3, n, if(n%2, -2*a065620((n - 1)/2) + 1, 2*a065620(n/2)));
    a065621(n) = bitxor(n, 2*(n - bitand(n, -n)));
    a(n) = x=a065620(n); if(n<2, n, if(x<0, a065621(1 + a(-x)), a048724(a(x - 1))));
    for(n=0, 100, print1(a(n),", ")) \\ Indranil Ghosh, Jun 07 2017
    
  • Python
    def a048724(n): return n^(2*n)
    def a065620(n): return n if n<3 else 2*a065620(n//2) if n%2==0 else -2*a065620((n - 1)//2) + 1
    def a065621(n): return n^(2*(n - (n & -n)))
    def a(n):
        x=a065620(n)
        return n if n<2 else a065621(1 + a(-x)) if x<0 else a048724(a(x - 1))
    print([a(n) for n in range(101)]) # Indranil Ghosh, Jun 07 2017

Formula

a(0) = 0, a(1) = 1, and for n > 1, if A065620(n) < 0, a(n) = A065621(1+a(-(A065620(n)))), otherwise a(n) = A048724(a(A065620(n)-1)).
Equally:
a(0) = 0, a(1) = 1, and for n > 1, if A010060(n) = 0, a(n) = A065621(1+a(A246159(n))), otherwise a(n) = A048724(a(A246160(n)-1)). [Note how A246159 is an inverse function for A048724, while A246160 is an inverse function for A065621].
As a composition of related permutations:
a(n) = A193231(A234025(n)).
a(n) = A234026(A193231(n)).
a(n) = A193231(A054429(A193231(n))).

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
Previous Showing 11-13 of 13 results.