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.

A386312 Numbers of people such that the last person is freed in the variant of the Josephus problem in which one person is skipped, then one is eliminated, then two people are skipped and one eliminated, then three people are skipped and so on.

This page as a plain text file.
%I A386312 #85 Aug 31 2025 08:58:33
%S A386312 1,7,10,12,21,25,28,235,822,24886,99607,101497,107716,5756103,55480598
%N A386312 Numbers of people such that the last person is freed in the variant of the Josephus problem in which one person is skipped, then one is eliminated, then two people are skipped and one eliminated, then three people are skipped and so on.
%C A386312 This sequence can also be described in terms of "AP dealing", in which one deals a deck of N cards into a new deck by moving one card to the bottom, dealing out the next card on top of the new deck, moving two cards to the bottom, etc. This sequence consists of all the deck sizes such that the bottom card of the deck moves to the top after AP dealing.
%C A386312 Numbers k such that A291317(k) = k.
%e A386312 Suppose there are people 1,2,3,4,5,6,7 in a circle. We first skip one person and eliminate the next, leaving people in order 3,4,5,6,7,1. Now, we skip two people and eliminate the next, leaving 6,7,1,3,4. Now, we skip three and eliminate the next, leaving 4,6,7,1. Now, we skip four and eliminate the next, leaving 6,7,1. Now, we skip five and eliminate the next, leaving 6,7. Finally, we skip six and eliminate the next, leaving just 7. As the last person in the circle was freed, 7 belongs to this sequence.
%o A386312 (Python)
%o A386312 def F(n):
%o A386312     c, i, J = 1, 0, list(range(1, n+1))
%o A386312     while len(J) > 1:
%o A386312         i = (i + c) % len(J)
%o A386312         q = J.pop(i)
%o A386312         c = c + 1
%o A386312     return J[0]
%o A386312 print([n for n in range(1, 100000) if F(n) == n])
%Y A386312 Cf. A182459, A291317, A385513, A386305.
%K A386312 nonn,more,new
%O A386312 1,2
%A A386312 _Tanya Khovanova_, _Nathan Sheffield_, and the MIT PRIMES STEP junior group, Aug 20 2025
%E A386312 a(15) from _Jinyuan Wang_, Aug 31 2025