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.

A385327 The numbers of people such that, in the variant of the Josephus problem in which three people are skipped and then one is eliminated, the first person is the last to be eliminated.

This page as a plain text file.
%I A385327 #11 Jul 05 2025 22:01:11
%S A385327 1,2,5,9,12,16,218,517,1226,6890,12249,16332,21776,38713,122353,
%T A385327 687461,1222153,51443354,385389994,1218022698,1624030264,2887164914,
%U A385327 5132737625,9124866889,28839085477,162036891790,910429504490,2877406829006,5115389918233,510385736583765
%N A385327 The numbers of people such that, in the variant of the Josephus problem in which three people are skipped and then one is eliminated, the first person is the last to be eliminated.
%C A385327 This sequence can be used in magic tricks with under-under-under-down dealing pattern. The deck sizes in this sequence guarantee that after the dealing, the last dealt card is the one that was initially on top.
%C A385327 The classical Josephus problem corresponds to under-down dealing. In this case, the first person is freed when the number of people is a power of 2: A000079.
%C A385327 If two people are skipped, then the corresponding sequence is A081614.
%e A385327 Suppose there are 5 people in a circle. After three people are skipped, the person number 4 is eliminated. The leftover people are 5,1,2,3 in order. Then person number 3 eliminated, and the leftover people are 5,1,2 in order. Then person number 5 is eliminated, and the leftover people are 1,2 in order. Then person number 2 is eliminated, and person 1 is freed. Thus, 5 is in this sequence.
%o A385327 (Python)
%o A385327 def freed_person_sequence_periodic(trailingUs, periodic_portion, numterms):
%o A385327     freed_person_table=[[0] for i in periodic_portion]
%o A385327     for i in range(numterms):
%o A385327         extend_freed_person_sequence(periodic_portion, freed_person_table)
%o A385327     return [(freed_person_table[0][N] - trailingUs)%(N+1)+1 for N in range(len(freed_person_table[0]))]
%o A385327 def extend_freed_person_sequence(periodic_portion, freed_person_table):
%o A385327     for offset in range(len(periodic_portion)):
%o A385327         first_death = periodic_portion[offset]
%o A385327         remaining_survivor = freed_person_table[(offset + 1)%len(periodic_portion)][len(freed_person_table[offset])-1]
%o A385327         if remaining_survivor + first_death + 1 < len(freed_person_table[offset])+ 1:
%o A385327             freed_person_table[offset].append(remaining_survivor + first_death + 1)
%o A385327         else:
%o A385327             freed_person_table[offset].append((remaining_survivor + first_death + 1) % (len(freed_person_table[offset]) + 1))
%o A385327 def first_freers_periodic(trailingUs, periodic_portion, numterms):
%o A385327     freed_seq = freed_person_sequence_periodic(trailingUs, periodic_portion, numterms)
%o A385327     return [i+1 for i in range(len(freed_seq)) if freed_seq[i] == 1]
%o A385327 print(first_freers_periodic(0, [3], 100000000))
%Y A385327 Cf. A000079, A081614, A088333, A384770, A384772, A384774, A385333.
%K A385327 nonn
%O A385327 1,2
%A A385327 _Tanya Khovanova_, _Nathan Sheffield_, and the MIT PRIMES STEP junior group, Jun 25 2025
%E A385327 More terms from _Jinyuan Wang_, Jul 01 2025