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.

A384991 Order of the permutation of [n] formed by a Josephus elimination variation: take p, skip 1, with p starting at 2 and advancing to the next prime after each skip.

This page as a plain text file.
%I A384991 #14 Jun 19 2025 18:41:58
%S A384991 1,1,2,3,3,5,4,7,8,15,10,11,12,13,45,15,105,17,77,19,24,21,117,23,504,
%T A384991 255,26,165,28,440,60,31,442,33,1386,805,154,37,105,39,1020,216,208,
%U A384991 43,40,45,2860,1953,90,49,45,51,1092,120,184,55,56,150,58,6045
%N A384991 Order of the permutation of [n] formed by a Josephus elimination variation: take p, skip 1, with p starting at 2 and advancing to the next prime after each skip.
%C A384991 The Josephus elimination begins with a circular list [n] from which successively take p elements and skip 1 where p begins at 2 and increases to the next prime (3,5,7,11,13,...) after each skip, and the permutation is the elements taken in the order they're taken.
%C A384991 Let p(k) be the k-th prime number, and let k increment with each move. In this variation, "take p(k), skip 1" means: move the p(k)-th element to the end of the list. After each move, counting begins from the element that replaced the moved one, and the next move targets the subsequent p(k+1)-th element. Thus, the positions of the elements being moved are p(k+1)-1 apart.
%C A384991    That is, the moved positions follow this progression:
%C A384991       Position Moved       Differences Between Positions
%C A384991       ===================  =============================
%C A384991                2 - 1 =  1      1 -  0 =  1    (=  2 - 1)
%C A384991         (1) +  3 - 1 =  3      3 -  1 =  2    (=  3 - 1)
%C A384991         (3) +  5 - 1 =  7      7 -  3 =  4    (=  5 - 1)
%C A384991         (7) +  7 - 1 = 13     13 -  7 =  6    (=  7 - 1)
%C A384991        (13) + 11 - 1 = 23     23 - 13 = 10    (= 11 - 1)
%C A384991               ^^        .               ^^             .
%C A384991               p(k)      .           p(k)-1             .
%C A384991                         .                              .
%C A384991 A given element can be moved multiple times before reaching its final position.
%H A384991 Chuck Seggelin, <a href="/A384991/b384991.txt">Table of n, a(n) for n = 1..1000</a>
%e A384991 For n=15, the rotations to construct the permutation are
%e A384991     1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
%e A384991        \----------------------------------------------/  1st rotation (p=2)
%e A384991     1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 2
%e A384991              \----------------------------------------/  2nd rotation (p=3)
%e A384991     1, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 2, 5
%e A384991                           \---------------------------/  3rd rotation (p=5)
%e A384991     1, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 2, 5, 10
%e A384991                                                 \-----/  4th rotation (p=7)
%e A384991     1, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 2, 10, 5
%e A384991 The 4th rotate is an example of an element (5) which was previously rotated to the end, being rotated to the end again.
%e A384991 This final permutation has order a(15) = 45 (applying it 45 times reaches the identity permutation again).
%o A384991 (Python)
%o A384991 from sympy.combinatorics import Permutation
%o A384991 from sympy import isprime, prime
%o A384991 def apply_transformation(seq):
%o A384991     k = 1
%o A384991     p = prime(k)
%o A384991     i = p - 1
%o A384991     while i < len(seq):
%o A384991         seq.append(seq.pop(i))
%o A384991         k += 1
%o A384991         p = prime(k)
%o A384991         i += (p-1)
%o A384991     return seq
%o A384991 def a(n):
%o A384991     seq = list(range(n))
%o A384991     p = apply_transformation(seq.copy())
%o A384991     return Permutation(p).order()
%Y A384991 Cf. A000040, A051732 (Josephus elimination permutation order), A384753 (take 2 skip 1 Josephus variation), A384989 (take 3 skip 1 Josephus variation), A384990 (take k skip 1 Josephus variation).
%K A384991 nonn
%O A384991 1,3
%A A384991 _Chuck Seggelin_, Jun 14 2025