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.

Showing 1-3 of 3 results.

A325594 Last remaining numbers after a symmetric variation of the Josephus problem.

Original entry on oeis.org

1, 1, 3, 4, 3, 6, 1, 3, 9, 1, 11, 5, 11, 7, 9, 14, 5, 12, 7, 12, 11, 14, 9, 22, 5, 20, 7, 28, 3, 30, 1, 11, 25, 9, 27, 5, 35, 7, 33, 3, 41, 1, 43, 5, 43, 7, 41, 19, 33, 17, 35, 13, 43, 15, 41, 27, 33, 25, 35, 29, 35, 31
Offset: 1

Views

Author

Gordon Atkinson, Sep 07 2019

Keywords

Comments

A variant of the Josephus problem where two numbers are eliminated at every stage, one elimination clockwise, the other counterclockwise. To resolve ambiguities, the usual Josephus problem takes precedence.

Crossrefs

Programs

  • Mathematica
    joseboth[m_, mm_] := Block[{t, p, q, u, v, w}, w = mm - 1; t = Range[m]; p = t; q = t; Do[p = RotateLeft[p, w]; u = First[p]; p = Rest[p]; q = Drop[q, Position[q, u][[1]]]; If[Length[p] == 1, Break[],]; q = RotateRight[q, w]; v = Last[q]; q = Drop[q, -1]; p = Drop[p, Position[p, v][[1]]]; If[Length[q] == 1, Break[],], {n, 1, Ceiling[m/2]}]; p[[1]]];

Formula

A165556(n) = a(n) mod 2.

A165728 If we divide the sequence into these subsequences, the pattern is obvious. {{1,1}, {0,1}, {1,1}}, {{0,1,0,1}, {1,1,1,1}, {0,1,0,1}}, {{1,1,1,1,1,1,1,1}, {0,1,0,1,0,1,0,1}, {1,1,1,1,1,1,1,1}}, {{0,1,0,1,0,1,0,1,0,1,0,1,0,1,0}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1}}, ...

Original entry on oeis.org

1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1
Offset: 1

Views

Author

Ryohei Miyadera and Masakazu Naito, Sep 25 2009

Keywords

Comments

This is a sequence made by a variant of the Josephus Problem mod 2, but we use the last number to eliminate instead the last number that remains.
We put n numbers in a circle, and in this variant two numbers are to be eliminated at the same time.
These two processes of elimination go in different directions. Suppose that there are n numbers. Then the first process of elimination starts with the first number and the 2nd, 4th, 6th numbers, ... are to be eliminated.
The second process starts with the n-th number, and the (n-1)-st, (n-3)-rd, (n-5)-th number, ... are to be eliminated.
We suppose that the first process comes first and the second process second at every stage.
We denote by JI2(n) the position of the last number to be eliminated when we have n numbers.
If we use this sequence JI2(n) for n = 6,7,8,... under mod 2, then we get the above sequence with 1 and 0.
Note that we have to omit the first 5 terms to get this sequence with its beautiful pattern.

Examples

			Suppose that there are n = 14 numbers. Then the 2nd, 4th, and 6th numbers will be eliminated by the first process. Similarly 13th, 11th, and 9th numbers will be eliminated by the second process. Now two directions are going to overlap. The first process will eliminate the 8 and 12 and the second process will eliminate 5 and 1. After this the first process will eliminate 3 and 14, and the second process will eliminate 10. The number that remains is 7, and hence the last number to be eliminated is 14. Therefore JI2(14) = 14. JI2(14) = 0 (mod 2).
		

Crossrefs

Programs

  • Mathematica
    last2 = {1, 2, 1, 1, 1, 3, 5, 6, 5, 5}; Table[JI2[n] = last2[[n]], {n, 1, 10}]; JI2[m_] := JI2[m] = Block[{n, h}, h = Mod[m, 8]; n = (m - h)/8; Which[h == 0, 4 JI2[2 n] - 1 - Floor[JI2[2 n]/(n + 1)], h == 1, 8 n + 5 - 4 JI2[2 n], h == 2, 4 JI2[2 n] -3 -Floor[JI2[2 n]/(n + 2)], h == 3, 8 n + 7 - 4 JI2[2 n], h == 4, 8 n + 8 - 4 JI2[2 n + 1] + Floor[JI2[2 n + 1]/(n + 2)], h == 5, 4 JI2[2 n + 1] - 1, h == 6, 8 n + 10 - 4 JI2[2 n + 1] + Floor[JI2[2 n + 1]/(n + 2)], h == 7, 4 JI2[2 n + 1] - 3]]; Table[Mod[JI2[n], 2], {n, 6, 95}]

Formula

{JI2(n): n = 1,2,3,4,5,6,7,8} = {1, 2, 1, 1, 1, 3, 5}.
(1) JI2(8*n) = 4*JI2(2*n) - 1 - [JI2(2*n)/(n+1) ].
(2) JI2(8*n+1) = 8*n + 5 - 4*JI2(2*n).
(3) JI2(8*n+2) = 4*JI2(2*n) - 3 - [JI2(2*n)/(n + 2)] .
(4) JI2(8*n+3) = 8*n + 7 - 4*JI2(2*n).
(5) JI2(8*n+4) = 8*n + 8 - 4*JI2(2*n+1) + [JI2(2*n+1)/(n+2)].
(6) JI2(8*n+5) = 4*JI2(2*n+1) - 1.
(7) JI2(8*n+6) = 8*n + 10 - 4*JI2(2*n+1) + [JI2(2*n+1)/(n+2)].
(8) JI2(8*n+7) = 4*JI2(2*n+1) - 3,
Note that recurrence relations are the same as those of A165556, but initial values are different.

A165735 Surviving integers under the double-count Josephus problem (see A054995), modulo 3.

Original entry on oeis.org

1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
Offset: 1

Views

Author

Ryohei Miyadera and Masakazu Naito, Sep 25 2009

Keywords

Comments

Old name was: The pattern is obvious. The sequence can be divided into subsequences of {1,1,1,...} and {2,2,2,...}.
Let n be a natural number. We put n numbers in a circle, and we are going to remove every third number. Let J3(n) be the last number that remains. This is the traditional Josephus Problem. Let J3 (mod 3) be the residue of the sequence J3(n) under mod 3. J3 (mod 3) produces the sequence {1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,...}.

Examples

			If we use n = 10, then we put numbers 1,2,3,4,5,6,7,8,9,10 in a circle. We eliminate 3,6,9,2,7,1,8,5,10, and the last number that remains is 4. Therefore J3(10) = 4 and J3(10) = 1 mod 3.
		

Crossrefs

Programs

  • Mathematica
    J3[1] = 1; J3[2] = 2; J3[n_] := J3[n] = Block[{m, t}, t = Mod[n, 3]; m = (n - t)/3; Which[t == 0, J3[2 m] + Floor[(J3[2 m] - 1)/2], t == 1, If[J3[2 m + 1] == 1, 3 m + 1, J3[2 m + 1] + Floor[J3[2 m + 1]/2] - 2], t == 2, J3[2 m + 1] + Floor[J3[2 m + 1]/2] + 1]]; Table[Mod[J3[n], 3], {n, 1, 200}]

Formula

(1) J3(1) = 1 and J3(2) = 2.
(2) J3(3m) = J3(2m) + [(J3(2m)-1)/2].
(3a) J3(3m+1) = 3m + 1 (if J3(2m + 1) = 1).
(3b) J3(3m+1) = J3(2m+1) + [J3(2m+1)/2] - 2 (if J3(2m + 1) > 1).
(4) J3(3m+2) = J3(2m+1) + [J3(2m+1)/2] + 1
a(n) = A010872(A054995(n)). - Gordon Atkinson, Aug 21 2019

Extensions

New name from Gordon Atkinson, Aug 21 2019
Showing 1-3 of 3 results.