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 A152423 #54 Feb 16 2025 08:33:09 %S A152423 1,2,2,4,2,4,6,8,2,4,6,8,10,12,14,16,2,4,6,8,10,12,14,16,18,20,22,24, %T A152423 26,28,30,32,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40, %U A152423 42,44,46,48,50,52,54,56,58,60,62,64,2,4,6,8,10,12,14,16,18,20 %N A152423 A variation of the Josephus problem, removing every other person, starting with person 1; a(n) is the last person remaining. %C A152423 Begin with n people standing in a circle, numbered clockwise 1 through n. Until only one person remains, go around the circle clockwise, removing every other person, starting by removing person 1. a(n) is the number of the last person remaining. %C A152423 Apparently a(n) = 2*A062050(n-1), n > 1. - _Paul Curtz_, May 30 2011 %H A152423 Alois P. Heinz, <a href="/A152423/b152423.txt">Table of n, a(n) for n = 1..8192</a> %H A152423 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/JosephusProblem.html">Josephus Problem</a> %H A152423 Wikipedia, <a href="https://en.wikipedia.org/wiki/Josephus_problem">Josephus problem</a> %H A152423 <a href="/index/J#Josephus">Index entries for sequences related to the Josephus Problem</a> %F A152423 a(1)=1, a(2)=2; for n > 2, a(n)=2 if n < a(n-1) + 2, otherwise a(n) = a(n-1) + 2. %F A152423 a(n)=n if n is a power of 2, otherwise a(n)=2*(n-2^m) where m is the exponent of the nearest power of 2 below n. - _Nicolas Patrois_, Apr 19 2021 %F A152423 a(n) = 2*n - 2^ceiling(log_2(n)). - _Alois P. Heinz_, Nov 22 2023 %e A152423 From _Omar E. Pol_, Dec 16 2013: (Start) %e A152423 It appears that this is also an irregular triangle with row lengths A011782 as shown below: %e A152423 1; %e A152423 2; %e A152423 2,4; %e A152423 2,4,6,8; %e A152423 2,4,6,8,10,12,14,16; %e A152423 2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32; %e A152423 2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40, 42,44,46,48,50,52,54,56,58,60,62,64; %e A152423 Right border gives A000079. %e A152423 (End) %p A152423 a:= n-> 2*n - 2^ceil(log[2](n)): %p A152423 seq(a(n), n=1..74); # _Alois P. Heinz_, Nov 22 2023 %t A152423 A152423[n_]:=2n-2^Ceiling[Log2[n]];Array[A152423,100] (* _Paolo Xausa_, Nov 23 2023 *) %o A152423 (PHP) function F($in){ $a[1] = 1; if($in == 1){ return $a;} $temp =2; for($i=2;$i<=$in;$i++){ $temp+=2; if($temp>$i){ $temp = 2 ; } $answer[] = $temp; } return $answer; } #change $n value for the result $n=5; #sequence store in $answer by using $a = F($n); #to display a(n) echo $a[n]; %o A152423 (Python) m=len(bin(n))-3; print(n if 2**m==n else 2*(n-2**m)) # _Nicolas Patrois_, Apr 19 2021 %Y A152423 The Index to the OEIS lists 21 entries under "Josephus problem". - _N. J. A. Sloane_, Dec 04 2008 %Y A152423 Cf. A000079, A011782, A062050. %K A152423 easy,nonn %O A152423 1,2 %A A152423 Suttapong Wara-asawapati (retsam_krad(AT)hotmail.com), Dec 03 2008 %E A152423 Edited by _Jon E. Schoenfield_, Feb 29 2020