Cody

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

Solution 1701562

Submitted on 2 Jan 2019
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   Fail
n = 0; k_correct = 1; assert(isequal(num_ones(n),k_correct))

Undefined function 'de2bi' for input arguments of type 'double'. Error in num_ones (line 2) count(de2bi(10^n),'1'); Error in Test1 (line 3) assert(isequal(num_ones(n),k_correct))

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

Undefined function 'de2bi' for input arguments of type 'double'. Error in num_ones (line 2) count(de2bi(10^n),'1'); Error in Test2 (line 3) assert(isequal(num_ones(n),k_correct))

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

Undefined function 'de2bi' for input arguments of type 'double'. Error in num_ones (line 2) count(de2bi(10^n),'1'); Error in Test3 (line 3) assert(isequal(num_ones(n),k_correct))

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

Undefined function 'de2bi' for input arguments of type 'double'. Error in num_ones (line 2) count(de2bi(10^n),'1'); Error in Test4 (line 3) assert(isequal(num_ones(n),k_correct))

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

Undefined function 'de2bi' for input arguments of type 'double'. Error in num_ones (line 2) count(de2bi(10^n),'1'); Error in Test5 (line 3) assert(isequal(num_ones(n),k_correct))

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

Undefined function 'de2bi' for input arguments of type 'double'. Error in num_ones (line 2) count(de2bi(10^n),'1'); Error in Test6 (line 3) assert(isequal(num_ones(n),k_correct))

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

Undefined function 'de2bi' for input arguments of type 'double'. Error in num_ones (line 2) count(de2bi(10^n),'1'); Error in Test7 (line 3) assert(isequal(num_ones(n),k_correct))

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

Undefined function 'de2bi' for input arguments of type 'double'. Error in num_ones (line 2) count(de2bi(10^n),'1'); Error in Test8 (line 3) assert(isequal(num_ones(n),k_correct))

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

Undefined function 'de2bi' for input arguments of type 'double'. Error in num_ones (line 2) count(de2bi(10^n),'1'); Error in Test9 (line 3) assert(isequal(num_ones(n),k_correct))

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

Undefined function 'de2bi' for input arguments of type 'double'. Error in num_ones (line 2) count(de2bi(10^n),'1'); Error in Test10 (line 3) assert(isequal(num_ones(n),k_correct))