Cody

# Problem 1226. Non-zero bits in 10^n.

Solution 197092

Submitted on 26 Jan 2013 by Richard Zapor
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% n = 0; k_correct = 1; assert(isequal(num_ones(n),k_correct))

``` k = 1 ```

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

``` k = 0 k = 1 k = 1 k = 2 ```

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

``` k = 0 k = 0 k = 1 k = 1 k = 1 k = 2 k = 3 ```

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

``` k = 0 k = 0 k = 0 k = 0 k = 0 k = 1 k = 1 k = 2 k = 2 k = 3 k = 4 k = 4 k = 4 k = 4 k = 4 k = 5 k = 6 ```

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

``` k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 1 k = 1 k = 1 k = 2 k = 3 k = 4 k = 5 k = 6 k = 6 k = 7 k = 7 k = 7 k = 7 k = 7 k = 7 k = 7 k = 8 k = 8 k = 9 k = 9 k = 10 k = 10 k = 10 k = 11 ```

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

``` k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 1 k = 1 k = 2 k = 3 k = 3 k = 3 k = 3 k = 4 k = 5 k = 5 k = 5 k = 6 k = 6 k = 6 k = 7 k = 7 k = 8 k = 8 k = 9 k = 10 k = 11 k = 12 k = 13 k = 14 k = 14 k = 15 k = 15 k = 16 k = 17 k = 17 k = 17 k = 17 k = 18 k = 19 k = 20 ```

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

``` k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 1 k = 1 k = 1 k = 2 k = 2 k = 2 k = 3 k = 4 k = 4 k = 5 k = 5 k = 6 k = 6 k = 7 k = 8 k = 9 k = 9 k = 10 k = 11 k = 11 k = 11 k = 12 k = 12 k = 12 k = 13 k = 14 k = 14 k = 14 k = 14 k = 14 k = 14 k = 15 k = 16 k = 17 k = 18 k = 18 k = 18 k = 19 k = 20 k = 20 k = 20 k = 20 k = 20 k = 21 k = 22 k = 23 k = 24 k = 24 k = 24 k = 24 k = 24 k = 25 ```

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

``` k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 1 k = 1 k = 2 k = 3 k = 3 k = 4 k = 5 k = 6 k = 7 k = 7 k = 8 k = 8 k = 9 k = 9 k = 9 k = 10 k = 10 k = 11 k = 11 k = 11 k = 11 k = 11 k = 12 k = 13 k = 14 k = 15 k = 16 k = 17 k = 17 k = 17 k = 17 k = 18 k = 19 k = 19 k = 20 k = 20 k = 20 k = 20 k = 20 k = 20 k = 20 k = 21 k = 21 k = 22 k = 23 k = 23 k = 24 k = 24 k = 24 k = 25 k = 25 k = 26 k = 26 k = 27 ```

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

``` k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 1 k = 1 k = 2 k = 2 k = 3 k = 3 k = 3 k = 3 k = 4 k = 4 k = 4 k = 5 k = 6 k = 6 k = 7 k = 7 k = 7 k = 7 k = 7 k = 7 k = 7 k = 7 k = 7 k = 7 k = 8 k = 8 k = 9 k = 9 k = 9 k = 9 k = 10 k = 10 k = 11 k = 12 k = 12 k = 13 k = 14 k = 15 k = 15 k = 16 k = 17 k = 18 k = 19 k = 19 k = 20 k = 20 k = 20 k = 20 k = 21 k = 22 k = 23 k = 23 k = 23 k = 24 k = 25 k = 26 k = 27 k = 27 k = 27 k = 28 k = 28 k = 28 k = 29 k = 30 k = 31 k = 31 k = 32 k = 32 k = 33 k = 34 k = 34 k = 34 k = 34 k = 34 k = 35 k = 35 k = 35 k = 35 k = 35 k = 35 k = 36 k = 37 k = 38 k = 39 k = 40 k = 41 k = 42 k = 42 k = 43 k = 44 k = 44 k = 45 k = 46 k = 47 k = 47 k = 48 k = 48 k = 49 k = 50 k = 50 k = 50 k = 51 k = 52 k = 52 k = 53 ```

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

``` k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 0 k = 1 k = 1 k = 1 k = 1 k = 2 k = 3 k = 4 k = 5 k = 5 k = 5 k = 5 k = 6 k = 6 k = 7 k = 8 k = 9 k = 9 k = 10 k = 10 k = 10 k = 10 k = 10 k = 10 k = 11 k = 11 k = 12 k = 12 k = 13 k = 13 k = 13 k = 13 k = 14 k = 14 k = 14 k = 14 k = 14 k = 15 k = 16 k = 16 k = 16 k = 16 k = 16 k = 17 k = 17 k = 17 k = 18 k = 18 k = 18 k = 19 k = 20 k = 20 k = 21 k = 21 k = 22 k = 22 k = 23 k = 23 k = 24 k = 24 k = 25 k = 25 k = 25 k = 26 k = 27 k = 28 k = 29 k = 30 k = 30 k = 30 k = 31 k = 31 k = 32 k = 33 k = 33 k = 33 k = 33 k = 34 k = 34 k = 34 k = 34 k = 34 k = 35 k = 35 k = 35 k = 35 k = 36 k = 37 k = 38 k = 38 k = 38 k = 38 k = 39 k = 39 k = 39 k = 39 k = 39 k = 39 k = 39 k = 40 k = 40 k = 40 k = 41 k = 42 k = 43 k = 43 k = 43 k = 44 k = 45 k = 45 k = 46 k = 46 k = 47 k = 47 k = 47 k = 47 k = 48 k = 49 k = 50 k = 50 k = 50 k = 51 k = 52 k = 53 k = 54 k = 55 k = 56 k = 56 k = 57 k = 57 k = 57 k = 57 k = 57 k = 57 k = 58 k = 59 k = 60 k = 60 k = 60 k = 61 k = 62 k = 62 k = 62 k = 63 k = 63 k = 63 k = 63 k = 64 k = 65 k = 65 k = 65 k = 66 k = 66 k = 66 k = 66 k = 66 k = 67 k = 68 k = 69 k = 70 k = 70 k = 70 k = 71 k = 71 k = 71 k = 72 k = 73 k = 73 k = 74 k = 74 k = 74 k = 74 k = 74 k = 75 k = 76 k = 76 k = 77 k = 77 k = 78 k = 79 k = 80 k = 80 k = 80 k = 81 k = 82 k = 83 k = 84 k = 85 k = 85 k = 86 k = 87 k = 87 k = 87 k = 87 k = 87 k = 88 k = 89 k = 89 k = 89 k = 90 k = 90 k = 91 k = 91 k = 91 k = 92 k = 93 k = 93 k = 94 k = 94 k = 94 k = 95 k = 95 k = 95 k = 96 k = 96 k = 97 k = 98 k = 98 k = 99 k = 99 k = 100 k = 101 k = 101 k = 101 k = 102 k = 102 k = 102 k = 103 k = 103 k = 103 k = 104 k = 104 k = 104 k = 105 ```