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.
%I A337191 #49 Apr 17 2025 09:37:59 %S A337191 1,1,1,4,4,1,7,4,1,7,4,10,7,13,10,16,13,1,16,4,19,7,22,10,25,13,1,16, %T A337191 4,19,7,22,10,25,13,28,16,31,19,34,22,37,25,40,28,43,31,46,34,49,37, %U A337191 52,40,1,43,4,46,7,49,10,52,13,55,16,58,19,61,22,64,25,67 %N A337191 A version of the Josephus problem: a(n) is the surviving integer under the skip-eliminate-eliminate version of the elimination process. %C A337191 This variation of the Josephus problem is related to under-down-down card dealing. - _Tanya Khovanova_, Apr 14 2025 %H A337191 Harvey P. Dale, <a href="/A337191/b337191.txt">Table of n, a(n) for n = 1..1000</a> %H A337191 <a href="/index/J#Josephus">Index entries for sequences related to the Josephus Problem</a> %F A337191 a(1) = 1, a(2) = 1, a(n) = (a(n-2) + 3) (mod n) if (a(n-2) + 3) (mod n) is not 0; a(n) = n if (a(n-2) + 3) (mod n)=0. %F A337191 Any number n can be written as either 2*(3^k) + 2m (where 0 <= m < 3^k, k = 0,1,2,...) or 3^k + 2m (where 0 <= m < 3^k, k = 0,1,2,...), in either case a(n) = 3m + 1. %e A337191 Consider 4 people in a circle in order 1,2,3,4. In the first round, person 1 is skipped and persons 2 and 3 are eliminated. Now people are in order 4,1. In the second round, person 4 is skipped and person 1 is eliminated. Person 4 is freed. Thus, a(4) = 4. - _Tanya Khovanova_, Apr 14 2025 %t A337191 nxt[{n_,a_,b_}]:={n+1,b,If[Mod[a+3,n+1]!=0,Mod[a+3,n+1],n+1]}; NestList[nxt,{2,1,1},70][[;;,2]] (* _Harvey P. Dale_, Jul 27 2024 *) %o A337191 (PARI) a(n) = if (n <= 2, 1, my(x = (a(n-2) + 3) % n); if (x, x, n)); \\ _Michel Marcus_, Aug 20 2020 %o A337191 (PARI) a(n) = if (n<=1, return(1)); my(v=vector(n, i, i), w); while (#v > 3, if (#v <=3, w = [], w = vector(#v-3, k, v[k+3])); w = concat(w, Vec(v, 1)); v = w;); v[1]; \\ _Michel Marcus_, Mar 25 2025 %Y A337191 Cf. A006257, A225381, A321298, A378635, A381048, A381049, A382528. %K A337191 nonn %O A337191 1,4 %A A337191 _Robert W. Vallin_, Aug 18 2020 %E A337191 More terms from _Michel Marcus_, Aug 20 2020 %E A337191 Title corrected by _Tanya Khovanova_, Apr 14 2025