MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

### Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

# Solution 265012

Submitted on 21 Jun 2013 by Richard Zapor

Correct

39Size
Leading solution size is 24.
`This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.`

### Test Suite

Test
Code Input and Output
1
Pass

```%%
% Fixed 6/21/13
n=40;
k=7;
s_expect=24;
survivor=solve_josephus(n,k);
assert(isequal(survivor,s_expect))
```

2
Pass

```%%
n=4;
k=2;
s_expect=1;
survivor=solve_josephus(n,k);
assert(isequal(survivor,s_expect))
```

3
Pass

```%%
n=40;
k=2;
s_expect=17;
survivor=solve_josephus(n,k);
assert(isequal(survivor,s_expect))
```

4
Pass

```%%
n=37;
k=6;
s_expect=10;
survivor=solve_josephus(n,k);
assert(isequal(survivor,s_expect))
```

5
Pass

```%%
n=29;
k=28;
s_expect=3;
survivor=solve_josephus(n,k);
assert(isequal(survivor,s_expect))
```

6
Pass

```%%
n=101;
k=1;
s_expect=101;
survivor=solve_josephus(n,k);
assert(isequal(survivor,s_expect))
```