Cody

# Problem 2593. Polite numbers. N-th polite number.

Solution 512873

Submitted on 15 Oct 2014 by James
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
%% x = 1; y_correct = 3; assert(isequal(Nth_polite(x),y_correct))

j = @(x)length(dec2bin(x)) f = @(n)n+j(n+j(n)) ans = 3

2   Pass
%% x = 2; y_correct = 5; assert(isequal(Nth_polite(x),y_correct))

j = @(x)length(dec2bin(x)) f = @(n)n+j(n+j(n)) ans = 5

3   Pass
%% x = 4; y_correct = 7; assert(isequal(Nth_polite(x),y_correct))

j = @(x)length(dec2bin(x)) f = @(n)n+j(n+j(n)) ans = 7

4   Pass
%% x = 5; y_correct = 9; assert(isequal(Nth_polite(x),y_correct))

j = @(x)length(dec2bin(x)) f = @(n)n+j(n+j(n)) ans = 9

5   Pass
%% x = 7; y_correct = 11; assert(isequal(Nth_polite(x),y_correct))

j = @(x)length(dec2bin(x)) f = @(n)n+j(n+j(n)) ans = 11

6   Pass
%% x = 11; y_correct = 15; assert(isequal(Nth_polite(x),y_correct))

j = @(x)length(dec2bin(x)) f = @(n)n+j(n+j(n)) ans = 15

7   Pass
%% x = 12; y_correct = 17; assert(isequal(Nth_polite(x),y_correct))

j = @(x)length(dec2bin(x)) f = @(n)n+j(n+j(n)) ans = 17

8   Pass
%% x = 14; y_correct = 19; assert(isequal(Nth_polite(x),y_correct))

j = @(x)length(dec2bin(x)) f = @(n)n+j(n+j(n)) ans = 19

9   Pass
%% x = 19; y_correct = 24; assert(isequal(Nth_polite(x),y_correct))

j = @(x)length(dec2bin(x)) f = @(n)n+j(n+j(n)) ans = 24

10   Pass
%% x = 21; y_correct = 26; assert(isequal(Nth_polite(x),y_correct))

j = @(x)length(dec2bin(x)) f = @(n)n+j(n+j(n)) ans = 26

11   Pass
%% x = 27; y_correct = 33; assert(isequal(Nth_polite(x),y_correct))

j = @(x)length(dec2bin(x)) f = @(n)n+j(n+j(n)) ans = 33

12   Pass
%% x = 64; y_correct = 71; assert(isequal(Nth_polite(x),y_correct))

j = @(x)length(dec2bin(x)) f = @(n)n+j(n+j(n)) ans = 71

13   Pass
%% x = 1e6; y_correct = x+20; assert(isequal(Nth_polite(x),y_correct))

j = @(x)length(dec2bin(x)) f = @(n)n+j(n+j(n)) ans = 1000020

14   Pass
%% x = 1e7; y_correct = x+24; assert(isequal(Nth_polite(x),y_correct))

j = @(x)length(dec2bin(x)) f = @(n)n+j(n+j(n)) ans = 10000024

15   Pass
%% x = 999999999; y_correct = x+30; assert(isequal(Nth_polite(x),y_correct))

j = @(x)length(dec2bin(x)) f = @(n)n+j(n+j(n)) ans = 1.0000e+09