A051733
Numbers n such that A051732(n) = n-1.
Original entry on oeis.org
2, 3, 6, 7, 10, 15, 19, 27, 30, 31, 34, 42, 51, 54, 66, 70, 75, 82, 87, 90, 91, 99, 106, 114, 135, 147, 159, 174, 175, 187, 190, 195, 210, 211, 222, 231, 234, 246, 255, 262, 271, 274, 279, 282, 294, 307, 310, 327, 330, 331, 339, 351, 355, 379, 387, 394, 399, 411, 414
Offset: 1
Marie-Christine Haton (Marie-Christine.Haton(AT)loria.fr)
-
(* v8 *) Select[Range[2,4000],Function[n,Sort[First[First[PermutationCycles@Join[Table[2r-1,{r,1,n}],Table[2r-2n,{r,n+1,2n}]]]]]==Range[2,2n-1]]] (* Olivier Gérard, Nov 08 2012 *)
A163782
a(n) is the n-th J_2-prime (Josephus_2 prime).
Original entry on oeis.org
2, 5, 6, 9, 14, 18, 26, 29, 30, 33, 41, 50, 53, 65, 69, 74, 81, 86, 89, 90, 98, 105, 113, 134, 146, 158, 173, 174, 186, 189, 194, 209, 210, 221, 230, 233, 245, 254, 261, 270, 273, 278, 281, 293, 306, 309, 326, 329
Offset: 1
p(1,5)=3, p(2,5)=1, p(3,5)=5, p(4,5)=2 and p(5,5)=4.
So p=(1 3 5 4 2) and 5 is J_2-prime.
- R. L. Graham, D. E. Knuth & O. Patashnik, Concrete Mathematics (1989), Addison-Wesley, Reading, MA. Sections 1.3 & 3.3.
- P. R. J. Asveld, Table of n, a(n) for n = 1..6706
- Jean-Paul Allouche, Manon Stipulanti, and Jia-Yan Yao, Doubling modulo odd integers, generalizations, and unexpected occurrences, arXiv:2504.17564 [math.NT], 2025.
- P. R. J. Asveld, Permuting operations on strings and their relation to prime numbers, Discrete Applied Mathematics 159 (2011) 1915-1932.
- P. R. J. Asveld, Permuting operations on strings and the distribution of their prime numbers (2011), TR-CTIT-11-24, Dept. of CS, Twente University of Technology, Enschede, The Netherlands; alternative link.
- P. R. J. Asveld, Some Families of Permutations and Their Primes (2009), TR-CTIT-09-27, Dept. of CS, Twente University of Technology, Enschede, The Netherlands.
- Eric Weisstein's World of Mathematics, Josephus Problem
- Wikipedia, Josephus Problem
- Index entries for sequences related to the Josephus Problem
-
isJ2Prime(int n) { // for n > 1
int count = 0, leader = 0;
if (n % 4 == 1 || n % 4 == 2) { // small optimization
do {
leader = A025480(leader + n);
count++;
} while (leader != 0);
}
return count == n;
} // Joe Nellis, Jan 27 2023
-
lst = {};
Do[If[IntegerQ[(2^n + 1)/(2 n + 1)] && PrimitiveRoot[2 n + 1] == 2,
AppendTo[lst, n]], {n, 2, 10^5}]; lst (* Hilko Koning, Sep 21 2021 *)
-
Follow(s,f)={my(t=f(s),k=1); while(t>s, k++; t=f(t)); if(s==t, k, 0)}
ok(n)={my(d=2*n+1); n>1&&n==Follow(1,i->(d-((d-i)>>valuation(d-i, 2)))/2)}
select(n->ok(n),[1..1000]) \\ Andrew Howroyd, Nov 11 2017
-
forprime(p=5, 2000, if(znorder(Mod(2, p))==p-1, print1((p-1)/2, ", "))); \\ Andrew Howroyd, Nov 11 2017
A384753
Order of the permutation of {1,...,n} formed by a Josephus elimination variation: take 2, skip 1.
Original entry on oeis.org
1, 1, 1, 2, 3, 3, 5, 6, 4, 7, 9, 10, 5, 9, 13, 70, 12, 15, 84, 70, 52, 42, 21, 30, 15, 16, 38, 84, 168, 24, 90, 360, 120, 27, 24, 72, 30, 108, 286, 276, 105, 4680, 198, 36, 630, 234, 120, 2856, 54, 1056, 532, 660, 51, 310, 406, 54, 420, 120, 55, 264, 150
Offset: 1
For n=10, the rotations to construct the permutation are
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
\-----------------------/ 1st rotation
1, 2, 4, 5, 6, 7, 8, 9, 10, 3
\-----------------/ 2nd rotation
1, 2, 4, 5, 7, 8, 9, 10, 3, 6
\-----------/ 3rd rotation
1, 2, 4, 5, 7, 8, 10, 3, 6, 9
\----/ 4th rotation
1, 2, 4, 5, 7, 8, 10, 3, 9, 6
The 4th rotate is an example of an element (6) which was previously rotated to the end, being rotated to the end again.
This final permutation has order a(10) = 7 (applying it 7 times reaches the identity permutation again).
Cf.
A051732 (Josephus elimination permutation order).
-
from sympy.combinatorics import Permutation
def move_third(seq):
for i in range(2,len(seq),2):
seq.append(seq.pop(i))
return seq
def a(n):
seq = list(range(n))
p = move_third(seq.copy())
return Permutation(p).order()
A217948
List of numbers 2n for which the riffle permutation permutes all except the first and last of the 2n cards.
Original entry on oeis.org
4, 6, 12, 14, 20, 30, 38, 54, 60, 62, 68, 84, 102, 108, 132, 140, 150, 164, 174, 180, 182, 198, 212, 228, 270, 294, 318, 348, 350, 374, 380, 390, 420, 422, 444, 462, 468, 492, 510, 524, 542, 548, 558, 564, 588, 614, 620, 654, 660, 662, 678, 702, 710, 758, 774, 788, 798
Offset: 1
- Tiago Januario and Sebastian Urrutia, An Analytical Study in Connectivity of Neighborhoods for Single Round Robin Tournaments, 14th INFORMS Computing Society Conference, Richmond, Virginia, January 11-13, 2015, pp. 188-199; http://dx.doi.org/10.1287/ics.2015.0014
- Tiago Januario, S Urrutia, D de Werra, Sports scheduling search space connectivity: A riffle shuffle driven approach, Discrete Applied Mathematics, Volume 211, 1 October 2016, Pages 113-120; http://dx.doi.org/10.1016/j.dam.2016.04.018
-
(* v8 *) 2*Select[Range[2,1000],Function[n,Sort[First[First[ PermutationCycles@Join[Table[2r-1,{r,1,n}],Table[2r-2n,{r,n+1,2n}]]]]]== Range[2,2n-1]]] (* Olivier Gérard, Nov 08 2012 *)
A289386
Number of rounds of 'deal one, skip one' shuffling required to return a deck of n cards to its original order.
Original entry on oeis.org
1, 2, 3, 2, 5, 6, 5, 4, 6, 6, 15, 12, 12, 30, 15, 4, 17, 18, 10, 20, 21, 14, 24, 90, 63, 26, 27, 18, 66, 12, 210, 12, 33, 90, 35, 30, 110, 120, 120, 26, 41, 42, 105, 30, 45, 30, 60, 48, 120, 50, 42, 510, 53, 1680, 120, 1584, 57, 336, 276, 60, 2665, 720, 8415
Offset: 1
Cards are labeled 'A', 'B', 'C', etc. 'ABCD' is a deck with 'A' on top, 'D' on the bottom.
For n = 4:
Round 1:
Hand: ABCD Table: [empty] - initial state of Round 1
Hand: BCD Table: A - Deal one
Hand: CDB Table: A - Skip one
Hand: DB Table: CA - Deal one
Hand: BD Table: CA - Skip one
Hand: D Table: BCA - Deal one
Hand: D Table: BCA - Skip one
Hand: [empty] Table: DBCA - Deal one, end of Round 1
Round 2:
Hand: DBCA Table: [empty] - Initial state of Round 2
Hand: BCA Table: D - Deal one
Hand: CAB Table: D - Skip one
Hand: AB Table: CD - Deal one
Hand: BA Table: CD - Skip one
Hand: A Table: BCD - Deal one
Hand: A Table: BCD - Skip one
Hand [empty] Table: ABCD - Deal one, end of Round 2
The deck of 4 cards is in its original order ('ABCD') after 2 rounds, so a(4) = 2.
-
// see link
-
F:= proc(n)
local deck, table, i;
deck:= [$1..n];
table:= NULL;
for i from 1 to n-1 do
table:= deck[1],table;
deck:= deck[[$3..nops(deck),2]];
od:
ilcm(op(map(nops,convert([deck[1],table],'disjcyc'))));
end proc:
map(F, [$1..100]); # Robert Israel, Jul 06 2017
-
P[n_, i_] := Module[{d = 2i - 1}, While[d < n, d *= 2]; 2n - d];
Follow[s_, f_] := Module[{t = f[s], k = 1}, While[t > s, k++; t = f[t]]; If[s == t, k, 0]];
CyclePoly[n_, x_] := Module[{q = 0}, For[i = 1, i <= n, i++, l = Follow[i, P[n, #]&]; If[l != 0, q += x^l]]; q];
a[n_] := Module[{q = CyclePoly[n, x], m = 1}, For[i = 1, i <= Exponent[q, x], i++, If[Coefficient[q, x, i] != 0, m = LCM[m, i]]]; m];
Array[a, 60] (* Jean-François Alcover, Apr 09 2020, after Andrew Howroyd *)
-
deal(v)=my(deck=List(v),new=List(),cutoff=4000+#v,i=1); while(#deck>=i, listput(new,deck[i]); if(i++>#deck, break); listput(deck, deck[i]); if(#deck>cutoff, deck=List(deck[i+1..#deck]); i=0); i++); Vecrev(new)
ordered(v)=for(i=1,#v, if(v[i]!=i, return(0))); 1
a(n)=my(v=[1..n],t=1); while(!ordered(v=deal(v)), t++); t \\ Charles R Greathouse IV, Jul 06 2017
-
\\ alternative for larger n such as 2^n.
P(n,i)=my(d=2*i-1); while(ds, k++; t=f(t)); if(s==t, k, 0)}
CyclePoly(n, x)={my(q=0); for(i=1, n, my(l=Follow(i, j->P(n, j))); if(l, q+=x^l)); q}
a(n)={my(q=CyclePoly(n, x), m=1); for(i=1, poldegree(q), if(polcoeff(q, i), m=lcm(m, i))); m} \\ Andrew Howroyd, Nov 11 2017
A384989
Order of the permutation of [n] formed by a Josephus elimination variation: take 3, skip 1.
Original entry on oeis.org
1, 1, 1, 1, 2, 3, 4, 4, 6, 10, 6, 8, 12, 11, 9, 10, 42, 15, 16, 52, 60, 120, 18, 30, 140, 99, 95, 28, 90, 660, 30, 28, 30, 30, 546, 336, 48, 420, 24, 765, 1680, 60, 308, 400, 66, 462, 418, 4830, 252, 1430, 468, 49, 42, 180, 1020, 52, 2310, 264, 1680, 340, 380
Offset: 1
For n=11, the rotations to construct the permutation are
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
\------------------------/ 1st rotation
1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 4
\---------------/ 2nd rotation
1, 2, 3, 5, 6, 7, 9, 10, 11, 4, 8
\----/ 3rd rotation
1, 2, 3, 5, 6, 7, 9, 10, 11, 8, 4
The 3rd rotate is an example of an element (4) which was previously rotated to the end, being rotated to the end again.
This final permutation has order a(11) = 6 (applying it 6 times reaches the identity permutation again).
Cf.
A051732 (Josephus elimination permutation order),
A384753 (take 2 skip 1 Josephus variation).
-
from sympy.combinatorics import Permutation
def move_fourth(seq):
for i in range(3,len(seq),3):
seq.append(seq.pop(i))
return seq
def a(n):
seq = list(range(n))
p = move_fourth(seq.copy())
return Permutation(p).order()
A161172
a(n) is the order (or period) of the "Yummie" permutation applied to a set of n objects.
Original entry on oeis.org
1, 2, 3, 3, 5, 5, 6, 7, 15, 20, 11, 24, 24, 14, 6, 28, 17, 120, 55, 180, 21, 18, 60, 42, 90, 153, 140, 429, 56, 152, 60, 70, 483, 3640, 180, 272, 72, 1260, 180, 252, 174, 1260, 36, 442, 1404, 660, 47, 496, 240, 481, 48, 98, 570, 572
Offset: 1
a(9) = 15, because when the Yummie permutation is applied to {1,2,3,4,5,6,7,8,9} we get {6,2,4,8,9,7,5,3,1}, which corresponds to the product of a disjoint five cycle and a three cycle, and hence has order 15.
-
P(n,i)={if(i%2, n-(i\2), P(n\2, (n-i)\2+1))}
Follow(s, f)={my(t=f(s), k=1); while(t>s, k++; t=f(t)); if(s==t, k, 0)}
Cycles(n)={my(L=List()); for(i=1, n, my(k=Follow(i, j->P(n, j))); if(k, listput(L,k))); vecsort(Vec(L))}
a(n)={lcm(Cycles(n))} \\ Andrew Howroyd, Apr 28 2020
A333468
Length of the largest disjoint cycle of the permutation that results from the composition of first n circular shifts.
Original entry on oeis.org
1, 2, 2, 3, 5, 6, 3, 4, 9, 4, 7, 10, 9, 14, 4, 5, 7, 18, 8, 10, 7, 7, 14, 11, 6, 26, 12, 9, 29, 30, 5, 6, 33, 11, 21, 6, 11, 15, 22, 27, 41, 6, 17, 8, 8, 7, 22, 24, 15, 50, 28, 8, 53, 18, 22, 14, 25, 9, 15, 55, 14, 50, 6, 7, 65, 11, 19, 34, 69, 23, 35, 14, 22, 74, 10
Offset: 1
For n=3, the permutation (1)*(1,2)*(1,2,3)=(1)*(2,3), which is associated with the partition <2,1> of 3. The size of the largest part is 2, so a(3)=2.
For n=11, the permutation (1)*(1,2)*..*(1,2,..11)=(1,2,7,5)*(3,4,8,10,11,6,9) when rewritten as the product of disjoint cycles, which is associated with the partition <7,4> of 11. The size of the largest part is 7, so a(11)=7.
-
Follow(s, f)={my(t=f(s), k=1); while(t>s, k++; t=f(t)); if(s==t, k, 0)}
mkp(n)={my(v=vector(n,i,i)); for(k=1, n, my(t=v[1]); for(i=1, k-1, v[i]=v[i+1]); v[k]=t); v}
a(n)={my(v=mkp(n), m=0); for(i=1, n, m=max(m, Follow(i, j->v[j]))); m} \\ Andrew Howroyd, Mar 27 2020
A384184
Order of the permutation of {0,...,n-1} formed by successively swapping elements at i and 2*i mod n, for i = 0,...,n-1.
Original entry on oeis.org
1, 2, 1, 4, 2, 2, 2, 8, 3, 4, 5, 4, 6, 4, 6, 16, 4, 6, 9, 8, 4, 10, 28, 8, 10, 12, 9, 8, 14, 12, 12, 32, 5, 8, 70, 12, 18, 18, 24, 16, 10, 8, 7, 20, 210, 56, 126, 16, 110, 20, 60, 24, 26, 18, 120, 16, 9, 28, 29, 24, 30, 24, 60, 64, 6, 10, 33, 16
Offset: 1
For n = 11, the permutation is {0,3,4,7,8,1,2,9,10,5,6} and it has order a(11) = 5.
Cf.
A003418,
A000027,
A051732,
A004626,
A065119,
A001122,
A155072,
A001133,
A001134,
A001135,
A225759.
-
from sympy.combinatorics import Permutation
def a(n):
L = list(range(n))
for i in range(n):
if (j:= (i << 1) % n) != i:
L[i],L[j] = L[j],L[i]
return Permutation(L).order() # Darío Clavijo, Jun 05 2025
A384990
Order of the permutation of [n] formed by a Josephus elimination variation: take k, skip 1, with k starting at 1 and increasing by 1 after each skip.
Original entry on oeis.org
1, 1, 2, 2, 4, 5, 6, 7, 15, 9, 12, 11, 12, 13, 14, 60, 16, 70, 24, 88, 20, 60, 22, 23, 24, 25, 26, 27, 420, 29, 221, 31, 3465, 33, 285, 35, 840, 37, 38, 1040, 40, 41, 2618, 43, 44, 2520, 46, 546, 48, 594, 840, 644, 52, 696, 54, 2520, 56, 57, 58, 59, 60, 61, 62
Offset: 1
For n=10, the rotations to construct the permutation are
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
\--------------------------/ 1st rotation (k=1)
1, 3, 4, 5, 6, 7, 8, 9, 10, 2
\-----------------------/ 2nd rotation (k=2)
1, 3, 5, 6, 7, 8, 9, 10, 2, 4
\-----------------/ 3rd rotation (k=3)
1, 3, 5, 6, 8, 9, 10, 2, 4, 7
\-------/ 4th rotation (k=4)
1, 3, 5, 6, 8, 9, 10, 4, 7, 2
The 4th rotate is an example of an element (2) which was previously rotated to the end, being rotated to the end again.
This final permutation has order a(10) = 9 (applying it 9 times reaches the identity permutation again).
Cf.
A051732 (Josephus elimination permutation order),
A384753 (take 2 skip 1 Josephus variation),
A384989 (take 3 skip 1 Josephus variation).
Showing 1-10 of 11 results.
Comments