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

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

Opportunities for recent engineering grads.

# Solution 196510

Submitted on 25 Jan 2013 by SK

Correct

192Size
Leading solution size is 16.
`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

```%%
n = 0;
k_correct = 1;
assert(isequal(num_ones(n),k_correct))
```

2
Pass

```%%
n = 1;
k_correct = 2;
assert(isequal(num_ones(n),k_correct))
```

3
Pass

```%%
n = 2;
k_correct = 3;
assert(isequal(num_ones(n),k_correct))
```

4
Pass

```%%
n = 5;
k_correct = 6;
assert(isequal(num_ones(n),k_correct))
```

5
Pass

```%%
n = 10;
k_correct = 11;
assert(isequal(num_ones(n),k_correct))
```

6
Pass

```%%
n = 15;
k_correct = 20;
assert(isequal(num_ones(n),k_correct))
```

7
Pass

```%%
n = 22;
k_correct = 25;
assert(isequal(num_ones(n),k_correct))
```

8
Pass

```%%
n = 23;
k_correct = 27;
assert(isequal(num_ones(n),k_correct))
```

9
Pass

```%%
n = 45;
k_correct = 53;
assert(isequal(num_ones(n),k_correct))
```

10
Pass

```%%
n = 100;
k_correct = 105;
assert(isequal(num_ones(n),k_correct))
```