A382355 A version of the Josephus problem: a(n) is the surviving integer under the skip-eliminate-skip version of the elimination process.
1, 1, 1, 4, 3, 6, 3, 6, 9, 3, 6, 9, 12, 1, 4, 7, 10, 13, 16, 19, 1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, 3, 6
Offset: 1
Keywords
Examples
Consider 4 people in a circle in order 1,2,3,4. In the first round, person 1 is skipped, then person 2 is eliminated, then person 3 is skipped. Now people are in order 4,1,3. In the second round, person 4 is skipped, person 1 is eliminated, and person 3 is skipped. Now people are in order 4,3. In the third round person 3 is eliminated. Person 4 is freed. Thus, a(4) = 4.
Programs
-
Python
def J(n,A): l=[] for i in range(n): l.append(i+1) index = 0 P=[] for i in range(n): index+=A[i] index=index%len(l) P.append(l[index]) l.pop(index) return P def invPerm(p): inv = [] for i in range(len(p)): inv.append(None) for i in range(len(p)): inv[p[i]-1]=i+1 return inv def survivor(n, A): return J(n, A)[n-1] def UDU(n): return [1] + [2 for i in range(n)] seq = [] for i in range(1,20): seq += [survivor(i, UDU(i))] print(", ".join([str(v) for v in seq]))
-
Python
def a(n): c, i, J = 1, 0, list(range(1, n+1)) while len(J) > 1: i = (i + 1)%len(J) q = J.pop(i) i = (i + 1)%len(J) # skip the third return J[0] print([a(n) for n in range(1, 73)]) # Michael S. Branicky, Mar 24 2025
Comments