A005427
Josephus problem: numbers m such that, when m people are arranged on a circle and numbered 1 through m, the final survivor when we remove every 4th person is one of the first three people.
Original entry on oeis.org
5, 7, 9, 12, 16, 22, 29, 39, 52, 69, 92, 123, 164, 218, 291, 388, 517, 690, 920, 1226, 1635, 2180, 2907, 3876, 5168, 6890, 9187, 12249, 16332, 21776, 29035, 38713, 51618, 68824, 91765, 122353, 163138, 217517, 290023, 386697, 515596, 687461, 916615, 1222153, 1629538, 2172717, 2896956, 3862608, 5150144, 6866859, 9155812, 12207749, 16276999, 21702665, 28936887, 38582516, 51443354
Offset: 1
From _Petros Hadjicostas_, Jul 22 2020: (Start)
We explain why 5 and 7 are in the sequence but 6 is not.
If we put m = 5 people on the circle, label them 1 through 5, start the counting at person 1, and remove every 4th person, then the list of people who are removed is 4 -> 3 -> 5 -> 2. Thus, the last survivor is 1, so m = 5 is included in this sequence.
If we put m = 6 people on a circle, label them 1 through 6, start the counting at person 1, and remove every 4th person, then the list of people who are removed is 4 -> 2 -> 1 -> 3 -> 6. Thus, the last survivor is 5 (not 1, 2, or 3), so m = 6 is not included in this sequence.
If we put m = 7 people on a circle, label them 1 through 7, start the counting at person 1, and remove every 4th person, then the list of people who are removed is 4 -> 1 -> 6 -> 5 -> 7 -> 3. Thus, the last survivor is 2, so m = 7 is included in this sequence.
Strictly speaking, m = 2 and m = 3 should have been included as well (since clearly the last survivor would be 1 or 2 or 3). In addition, m = 4 should have been included as well because the list of people removed is 4 -> 1 -> 3. The case of number 1 does create a problem since there is no survivor. Note that the numbers 1, 2, 3, 4 are all included in A072493. (End)
- Fred Schuh, The Master Book of Mathematical Recreations, Dover, New York, 1968. [This book is cited in Burde (1987). Table 18, p. 374, is related to a very similar sequence (A073941). Thus, definitely, the counting-off games described in the book are related to a similar counting-off game in Burde (1987).]
- N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
- Vincenzo Librandi, Table of n, a(n) for n = 1..1000
- K. Burde, Das Problem der Abzählreime und Zahlentwicklungen mit gebrochenen Basen [The problem of counting rhymes and number expansions with fractional bases], J. Number Theory 26(2) (1987), 192-209.
- Nicolas Thériault, Generalizations of the Josephus problem, Utilitas Mathematica, 58 (2000), 161-173 (MR1801309).
- Nicolas Thériault, Generalizations of the Josephus problem, Utilitas Mathematica, 58 (2000), 161-173 (MR1801309).
- Index entries for sequences related to the Josephus Problem
-
f[s_] := Append[s, Ceiling[5 + Plus@@(s/3)]]; Nest[f, {5}, 100] (* Vladimir Joseph Stephan Orlovsky, Jan 08 2011 *)
-
/* Gives an n X 2 matrix w s.t. w[,1] are the terms of this sequence and w[,2] are the corresponding numbers of the last survivors (1, 2 or 3). */
lista(nn) = {my(w = matrix(nn,2)); w[1,1] = 5; w[1,2] = 1; for(n=1, nn-1,
if(0 == w[n,1] % 3, w[n+1,1] = w[n,1]*4/3; w[n+1,2] = w[n,2]);
if(1 == w[n,1] % 3 && w[n,2] == 1, w[n+1,1] = ceil(w[n,1]*4/3); w[n+1,2] = w[n,2] + 2);
if(1 == w[n,1] % 3 && w[n,2] == 2, w[n+1,1] = floor(w[n,1]*4/3); w[n+1,2] = w[n,2] - 1);
if(1 == w[n,1] % 3 && w[n,2] == 3, w[n+1,1] = floor(w[n,1]*4/3); w[n+1,2] = w[n,2] - 1);
if(2 == w[n,1] % 3 && w[n,2] == 1, w[n+1,1] = ceil(w[n,1]*4/3); w[n+1,2] = w[n,2] + 1);
if(2 == w[n,1] % 3 && w[n,2] == 2, w[n+1,1] = ceil(w[n,1]*4/3); w[n+1,2] = w[n,2] + 1);
if(2 == w[n,1] % 3 && w[n,2] == 3, w[n+1,1] = floor(w[n,1]*4/3); w[n+1,2] = w[n,2] - 2);
); Vec(w[,1]);} \\ Petros Hadjicostas, Jul 21 2020
-
/* Second PARI program for the general case of Josephus problem. We use the Burde-Thériault algorithm, not the formula T(n;k) = ceiling(Sum_{s=1..n-1} T(s;k)/(k-1)). We start with T(k;k) = 1 (and omit all previous 1's). Burde starts with the smallest T(n;k) >= k whose corresponding last survivor is 1. This, however, can be very large. To get the corresponding last survivors, modify the program to get the vector j. */
lista(nn,k) = {my(j=vector(nn)); my(f=vector(nn)); my(N=vector(nn));
j[1]=1; f[1]=0; N[1] = 1;
for(n=1, nn-1, f[n+1] = ((j[n]-N[n]-1) % (k-1)) + 1 - j[n];
j[n+1] = j[n] + f[n+1]; N[n+1] = (k*N[n] + f[n+1])/(k-1););
for(n=1, nn, if(N[n] > k-1, print1(N[n],",")));} \\ Petros Hadjicostas, Jul 23 2020
More terms (from the Burde paper, p. 208) from
R. J. Mathar, Sep 26 2006
A087192
a(n) = ceiling(a(n-1)*4/3), with a(1) = 1.
Original entry on oeis.org
1, 2, 3, 4, 6, 8, 11, 15, 20, 27, 36, 48, 64, 86, 115, 154, 206, 275, 367, 490, 654, 872, 1163, 1551, 2068, 2758, 3678, 4904, 6539, 8719, 11626, 15502, 20670, 27560, 36747, 48996, 65328, 87104, 116139, 154852, 206470, 275294, 367059, 489412, 652550
Offset: 1
-
[n eq 1 select 1 else Ceiling(Self(n-1)*4/3): n in [1..50]]; // Vincenzo Librandi, Aug 17 2017
-
A[1]:= 1:
for n from 2 to 100 do A[n]:= ceil(4/3*A[n-1]) od:
seq(A[i],i=1..100); # Robert Israel, Aug 17 2017
-
a[1] = 1; a[n_] := a[n] = Ceiling[4 a[n - 1]/3]; Table[a@ n, {n, 45}] (* Michael De Vlieger, Jan 06 2016 *)
-
a(n) = if (n==1, 1, ceil(a(n-1)*4/3)) \\ Michel Marcus, Aug 01 2013
-
from fractions import Fraction
from functools import lru_cache
@lru_cache(maxsize=None)
def A087192(n): return int(Fraction(4*A087192(n-1),3)._ceil_()) if n>1 else 1 # Chai Wah Wu, Sep 07 2023
A120169
a(n) = 12 + floor((1 + Sum_{j=1..n-1} a(j))/4).
Original entry on oeis.org
12, 15, 19, 23, 29, 36, 45, 57, 71, 89, 111, 139, 173, 217, 271, 339, 423, 529, 661, 827, 1033, 1292, 1615, 2018, 2523, 3154, 3942, 4928, 6160, 7700, 9625, 12031, 15039, 18798, 23498, 29372, 36715, 45894, 57368, 71710
Offset: 1
-
function f(n, a, b)
t:=0;
for k in [1..n-1] do
t+:= a+Floor((b+t)/4);
end for;
return t;
end function;
g:= func< n, a, b | f(n+1, a, b)-f(n, a, b) >;
A120169:= func< n | g(n, 12, 1) >;
[A120169(n): n in [1..60]]; // G. C. Greubel, Sep 09 2023
-
nxt[{t_,a_}]:=Module[{c=Floor[(t+49)/4]},{t+c,c}]; NestList[nxt,{12,12},40][[All,2]] (* Harvey P. Dale, Jun 21 2017 *)
-
@CachedFunction
def f(n, p, q): return p + (q +sum(f(k, p, q) for k in range(1, n)))//4
def A120169(n): return f(n, 12, 1)
[A120169(n) for n in range(1, 61)] # G. C. Greubel, Sep 09 2023
A120135
a(n) = 5 + floor((1 + Sum_{j=1..n-1} a(j)) / 2).
Original entry on oeis.org
5, 8, 12, 18, 27, 40, 60, 90, 135, 203, 304, 456, 684, 1026, 1539, 2309, 3463, 5195, 7792, 11688, 17532, 26298, 39447, 59171, 88756, 133134, 199701, 299552, 449328, 673992, 1010988, 1516482, 2274723, 3412084, 5118126, 7677189, 11515784
Offset: 1
-
a[n_]:= a[n]= 5 +Floor[(1+Sum[a[k], {k,n-1}])/2];
Table[a[n], {n,60}] (* G. C. Greubel, May 07 2023 *)
-
@CachedFunction
def A120135(n): return 5 + (1 + sum(A120135(k) for k in range(1,n)))//2
[A120135(n) for n in range(1,61)] # G. C. Greubel, May 07 2023
A120136
a(n) = 7 + floor(Sum_{j=1..n-1} a(j) / 2).
Original entry on oeis.org
7, 10, 15, 23, 34, 51, 77, 115, 173, 259, 389, 583, 875, 1312, 1968, 2952, 4428, 6642, 9963, 14945, 22417, 33626, 50439, 75658, 113487, 170231, 255346, 383019, 574529, 861793, 1292690, 1939035, 2908552, 4362828, 6544242, 9816363, 14724545
Offset: 1
-
nxt[{t_,a_}] := Module[{c=7+Floor[t/2]},{t+c,c}];
NestList[nxt,{7,7},40][[All,2]] (* Harvey P. Dale, Jan 13 2017 *)
-
@CachedFunction
def A120136(n): return 7 +sum(A120136(k) for k in range(1,n))//2
[A120136(n) for n in range(1,60)] # G. C. Greubel, May 08 2023
A120137
a(n) = 8 + floor( (1 + Sum_{j=1..n-1} a(j)) / 2).
Original entry on oeis.org
8, 12, 18, 27, 41, 61, 92, 138, 207, 310, 465, 698, 1047, 1570, 2355, 3533, 5299, 7949, 11923, 17885, 26827, 40241, 60361, 90542, 135813, 203719, 305579, 458368, 687552, 1031328, 1546992, 2320488, 3480732, 5221098, 7831647, 11747471, 17621206
Offset: 1
-
a[n_]:= a[n]= 8 +Floor[(1 +Sum[a[k], {k,n-1}])/2];
Table[a[n], {n,60}] (* G. C. Greubel, May 08 2023 *)
nxt[{t_,a_}]:=Module[{c=8+Floor[(1+t)/2]},{t+c,c}]; NestList[nxt,{8,8},40][[;;,2]] (* Harvey P. Dale, Sep 10 2023 *)
-
@CachedFunction
def A120137(n): return 8 +(1 +sum(A120137(k) for k in range(1,n)))//2
[A120137(n) for n in range(1,60)] # G. C. Greubel, May 08 2023
A120138
a(n) = 10 + floor(Sum_{j=1..n-1} a(j) / 2).
Original entry on oeis.org
10, 15, 22, 33, 50, 75, 112, 168, 252, 378, 567, 851, 1276, 1914, 2871, 4307, 6460, 9690, 14535, 21803, 32704, 49056, 73584, 110376, 165564, 248346, 372519, 558779, 838168, 1257252, 1885878, 2828817, 4243226, 6364839, 9547258, 14320887
Offset: 1
-
a[n_]:= a[n]= 10 +Quotient[Sum[a[k], {k,n-1}],2];
Table[a[n], {n,60}] (* G. C. Greubel, May 08 2023 *)
-
@CachedFunction
def A120138(n): return 10 +sum(A120138(k) for k in range(1,n))//2
[A120138(n) for n in range(1,60)] # G. C. Greubel, May 08 2023
A120139
a(n) = 11 + floor( (1 + Sum_{j=1..n-1} a(j)) / 2).
Original entry on oeis.org
11, 17, 25, 38, 57, 85, 128, 192, 288, 432, 648, 972, 1458, 2187, 3280, 4920, 7380, 11070, 16605, 24908, 37362, 56043, 84064, 126096, 189144, 283716, 425574, 638361, 957542, 1436313, 2154469, 3231704, 4847556, 7271334, 10907001, 16360501
Offset: 1
-
a[n_]:= a[n]= 11 +Quotient[1 + Sum[a[k], {k,n-1}], 2];
Table[a[n], {n,60}] (* G. C. Greubel, May 08 2023 *)
-
@CachedFunction
def A120139(n): return 11 +(1 +sum(A120139(k) for k in range(1,n)))//2
[A120139(n) for n in range(1,60)] # G. C. Greubel, May 08 2023
A120140
a(n) = 13 + floor(Sum_{j=1..n-1} a(j)/2).
Original entry on oeis.org
13, 19, 29, 43, 65, 97, 146, 219, 328, 492, 738, 1107, 1661, 2491, 3737, 5605, 8408, 12612, 18918, 28377, 42565, 63848, 95772, 143658, 215487, 323230, 484845, 727268, 1090902, 1636353, 2454529, 3681794, 5522691, 8284036, 12426054, 18639081
Offset: 1
-
a[n_]:= a[n]= 13 +Quotient[Sum[a[k], {k,n-1}], 2];
Table[a[n], {n,60}] (* G. C. Greubel, May 11 2023 *)
-
@CachedFunction
def A120140(n): return 13 + sum(A120140(k) for k in range(1,n))//2
[A120140(n) for n in range(1,60)] # G. C. Greubel, May 11 2023
A120141
a(n) = 14 + floor( (1 + Sum_{j=0..n-1} a(j)) / 2).
Original entry on oeis.org
14, 21, 32, 48, 72, 108, 162, 243, 364, 546, 819, 1229, 1843, 2765, 4147, 6221, 9331, 13997, 20995, 31493, 47239, 70859, 106288, 159432, 239148, 358722, 538083, 807125, 1210687, 1816031, 2724046, 4086069, 6129104, 9193656, 13790484
Offset: 1
-
nxt[{t_,a_}]:=Module[{a2=14+Floor[(1+t)/2]},{t+a2,a2}]; NestList[nxt,{0,14},60][[All,2]]//Rest (* Harvey P. Dale, Nov 28 2018 *)
-
@CachedFunction
def A120141(n): return 14 +(1 +sum(A120141(k) for k in range(1,n)))//2
[A120141(n) for n in range(1,60)] # G. C. Greubel, May 11 2023
Comments