Cody

# Problem 2595. Polite numbers. Politeness.

Solution 1122711

Submitted on 14 Feb 2017 by mohammad z
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 = 0; assert(isequal(politeness(x),y_correct))

f = 1 f = [] rep = [] P = 0

2   Pass
x = 2; y_correct = 0; assert(isequal(politeness(x),y_correct))

f = 2 f = [] rep = [] P = 0

3   Pass
x = 3; y_correct = 1; assert(isequal(politeness(x),y_correct))

f = 3 f = 3 rep = 1 P = 1

4   Pass
x = 7; y_correct = 1; assert(isequal(politeness(x),y_correct))

f = 7 f = 7 rep = 1 P = 1

5   Pass
x = 9; y_correct = 2; assert(isequal(politeness(x),y_correct))

f = 3 3 f = 3 3 rep = 2 P = 2

6   Pass
x = 15; y_correct = 3; assert(isequal(politeness(x),y_correct))

f = 3 5 f = 3 5 rep = 1 1 P = 3

7   Pass
x = 18; y_correct = 2; assert(isequal(politeness(x),y_correct))

f = 2 3 3 f = 3 3 rep = 2 P = 2

8   Pass
x = 21; y_correct = 3; assert(isequal(politeness(x),y_correct))

f = 3 7 f = 3 7 rep = 1 1 P = 3

9   Pass
x = 1024; y_correct = 0; assert(isequal(politeness(x),y_correct))

f = 2 2 2 2 2 2 2 2 2 2 f = 1×0 empty double row vector rep = [] P = 0

10   Pass
x = 1025; y_correct = 5; assert(isequal(politeness(x),y_correct))

f = 5 5 41 f = 5 5 41 rep = 2 1 P = 5

11   Pass
x = 25215; y_correct = 11; assert(isequal(politeness(x),y_correct))

f = 3 5 41 41 f = 3 5 41 41 rep = 1 1 2 P = 11

12   Pass
x = 62; y_correct = 1; assert(isequal(politeness(x),y_correct))

f = 2 31 f = 31 rep = 1 P = 1

13   Pass
x = 63; y_correct = 5; assert(isequal(politeness(x),y_correct))

f = 3 3 7 f = 3 3 7 rep = 2 1 P = 5

14   Pass
x = 65; y_correct = 3; assert(isequal(politeness(x),y_correct))

f = 5 13 f = 5 13 rep = 1 1 P = 3

15   Pass
% anti-lookup & clue nums=primes(200); pattern=[1 nums([false ~randi([0 25],1,45)])]; x=prod(pattern)*2^randi([0 5]); y_correct=2^numel(pattern)/2-1; assert(isequal(politeness(x),y_correct))

f = 41 f = 41 rep = 1 P = 1

16   Pass
for k=randi(2e4,1,20) assert(isequal(politeness(k*(k-1))+1,(politeness(k)+1)*(politeness(k-1)+1))) end

f = 2 53 61 103 179 f = 53 61 103 179 rep = 1 1 1 1 P = 15 f = 61 179 f = 61 179 rep = 1 1 P = 3 f = 2 53 103 f = 53 103 rep = 1 1 P = 3 f = 2 2 2 3 13 31 53 337 f = 3 13 31 53 337 rep = 1 1 1 1 1 P = 31 f = 2 2 2 31 53 f = 31 53 rep = 1 1 P = 3 f = 3 13 337 f = 3 13 337 rep = 1 1 1 P = 7 f = 2 2 2 3 41 139 2137 f = 3 41 139 2137 rep = 1 1 1 1 P = 15 f = 3 41 139 f = 3 41 139 rep = 1 1 1 P = 7 f = 2 2 2 2137 f = 2137 rep = 1 P = 1 f = 2 11 11 37 2239 f = 11 11 37 2239 rep = 2 1 1 P = 11 f = 2 2239 f = 2239 rep = 1 P = 1 f = 11 11 37 f = 11 11 37 rep = 2 1 P = 5 f = 2 3 19 271 7723 f = 3 19 271 7723 rep = 1 1 1 1 P = 15 f = 3 19 271 f = 3 19 271 rep = 1 1 1 P = 7 f = 2 7723 f = 7723 rep = 1 P = 1 f = 2 2 5 2663 3329 f = 5 2663 3329 rep = 1 1 1 P = 7 f = 2 2 3329 f = 3329 rep = 1 P = 1 f = 5 2663 f = 5 2663 rep = 1 1 P = 3 f = 2 3 5 13 37 3607 f = 3 5 13 37 3607 rep = 1 1 1 1 1 P = 31 f = 3 5 13 37 f = 3 5 13 37 rep = 1 1 1 1 P = 15 f = 2 3607 f = 3607 rep = 1 P = 1 f = 2 2 2 5 307 491 f = 5 307 491 rep = 1 1 1 P = 7 f = 2 2 2 307 f = 307 rep = 1 P = 1 f = 5 491 f = 5 491 rep = 1 1 P = 3 f = 2 3 79 109 5741 f = 3 79 109 5741 rep = 1 1 1 1 P = 15 f = 3 5741 f = 3 5741 rep = 1 1 P = 3 f = 2 79 109 f = 79 109 rep = 1 1 P = 3 f = 2 3 3 1451 6529 f = 3 3 1451 6529 rep = 2 1 1 P = 11 f = 3 3 1451 f = 3 3 1451 rep = 2 1 P = 5 f = 2 6529 f = 6529 rep = 1 P = 1 f = 2 2 2 107 857 f = 107 857 rep = 1 1 P = 3 f = 857 f = 857 rep = 1 P = 1 f = 2 2 2 107 f = 107 rep = 1 P = 1 f = 2 2 2 3 71 193 571 f = 3 71 193 571 rep = 1 1 1 1 P = 15 f = 2 2 2 3 571 f = 3 571 rep = 1 1 P = 3 f = 71 193 f = 71 193 rep = 1 1 P = 3 f = 2 2 11 23 31 37 53 f = 11 23 31 37 53 rep = 1 1 1 1 1 P = 31 f = 2 2 37 53 f = 37 53 rep = 1 1 P = 3 f = 11 23 31 f = 11 23 31 rep = 1 1 1 P = 7 f = 2 3 5 223 6691 f = 3 5 223 6691 rep = 1 1 1 1 P = 15 f = 6691 f = 6691 rep = 1 P = 1 f = 2 3 5 223 f = 3 5 223 rep = 1 1 1 P = 7 f = 2 3 5 7 487 2087 f = 3 5 7 487 2087 rep = 1 1 1 1 1 P = 31 f = 2 3 5 487 f = 3 5 487 rep = 1 1 1 P = 7 f = 7 2087 f = 7 2087 rep = 1 1 P = 3 f = 2 13 19 23 23 181 f = 13 19 23 23 181 rep = 1 1 2 1 P = 23 f = 2 19 181 f = 19 181 rep = 1 1 P = 3 f = 13 23 23 f = 13 23 23 rep = 1 2 P = 5 f = 2 2 3 7 11 113 2131 f = 3 7 11 113 2131 rep = 1 1 1 1 1 P = 31 f = 7 2131 f = 7 2131 rep = 1 1 P = 3 f = 2 2 3 11 113 f = 3 11 113 rep = 1 1 1 P = 7 f = 2 2 2 2 2 2 2 2 3 3 3 31 223 f = 3 3 3 31 223 rep = 3 1 1 P = 15 f = 31 223 f = 31 223 rep = 1 1 P = 3 f = 2 2 2 2 2 2 2 2 3 3 3 f = 3 3 3 rep = 3 P = 3 f = 2 3 5 19 23 137 199 f = 3 5 19 23 137 199 rep = 1 1 1 1 1 1 P = 63 f = 2 3 23 137 f = 3 23 137 rep = 1 1 1 P = 7 f = 5 19 199 f = 5 19 199 rep = 1 1 1 P = 7 f = 2 2 2 3 5 239 3187 f = 3 5 239 3187 rep = 1 1 1 1 P = 15 f = 3 3187 f = 3 3187 rep = 1 1 P = 3 f = 2 2 2 5 239 f = 5 239 rep = 1 1 P = 3