Cody

# Problem 2595. Polite numbers. Politeness.

Solution 3607705

Submitted on 10 Nov 2020 by Mayank Bajpai
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))

P = 0

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

P = 0

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

t = 0 l = 2 P = 1

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

t = 4 l = 2 P = 1

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

t = 6 l = 2 t = 3 l = 3 P = 2

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

t = 12 l = 2 t = 9 l = 3 t = 0 l = 5 P = 3

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

t = 12 l = 3 t = 8 l = 4 P = 2

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

t = 18 l = 2 t = 15 l = 3 t = 0 l = 6 P = 3

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

P = 0

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

t = 1022 l = 2 t = 1010 l = 5 t = 970 l = 10 t = 700 l = 25 t = 164 l = 41 P = 5

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

t = 25212 l = 2 t = 25209 l = 3 t = 25200 l = 5 t = 25194 l = 6 t = 25160 l = 10 t = 25095 l = 15 t = 24750 l = 30 t = 24354 l = 41 t = 21812 l = 82 t = 17589 l = 123 t = 4100 l = 205 P = 11

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

t = 52 l = 4 P = 1

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

t = 60 l = 2 t = 57 l = 3 t = 42 l = 6 t = 35 l = 7 t = 18 l = 9 P = 5

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

t = 62 l = 2 t = 50 l = 5 t = 10 l = 10 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))

P = 0

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

t = 169143024 l = 3 t = 169143020 l = 4 t = 169143015 l = 5 t = 169143002 l = 7 t = 169142985 l = 9 t = 169142952 l = 12 t = 169142910 l = 15 t = 169142877 l = 17 t = 169142820 l = 20 t = 169142799 l = 21 t = 169142624 l = 28 t = 169142400 l = 35 t = 169142364 l = 36 t = 169141995 l = 45 t = 169141704 l = 51 t = 169141200 l = 60 t = 169141014 l = 63 t = 169140684 l = 68 t = 169139460 l = 84 t = 169139375 l = 85 t = 169137465 l = 105 t = 169135890 l = 119 t = 169133160 l = 140 t = 169131249 l = 153 t = 169126740 l = 180 t = 169122120 l = 204 t = 169111152 l = 252 t = 169110390 l = 255 t = 169101125 l = 289 t = 169093260 l = 315 t = 169085060 l = 340 t = 169079127 l = 357 t = 169054620 l = 420 t = 169029504 l = 476 t = 168965720 l = 595 t = 168955452 l = 612 t = 168850035 l = 765 t = 168766752 l = 867 t = 168711045 l = 929 t = 168622320 l = 1020 t = 168568974 l = 1071 t = 168474284 l = 1156 t = 168348600 l = 1260 t = 168122724 l = 1428 t = 168098295 l = 1445 t = 167549025 l = 1785 t = 167095754 l = 2023 t = 166309640 l = 2380 t = 165759129 l = 2601 t = 165257952 l = 2787 t = 164459700 l = 3060 t = 163127784 l = 3468 t = 162236844 l = 3716 t = 159964560 l = 4284 t = 159744750 l = 4335 t = 158352695 l = 4645 t = 154802340 l = 5355 t = 152435940 l = 5780 t = 150723615 l = 6069 t = 147995274 l = 6503 t = 143649660 l = 7140 t = 136398752 l = 8092 t = 134185689 l = 8361 t = 117981360 l = 10115 t = 115016220 l = 10404 t = 106998504 l = 11148 t = 84571515 l = 13005 t = 72043950 l = 13935 t = 44425709 l = 15793 t = 18796560 l = 17340 t = 3386502 l = 18207 P = 71 t = 12996 l = 4 t = 12978 l = 7 t = 12600 l = 28 P = 3 t = 13002 l = 2 t = 12999 l = 3 t = 12990 l = 5 t = 12984 l = 6 t = 12960 l = 9 t = 12950 l = 10 t = 12885 l = 15 t = 12852 l = 17 t = 12834 l = 18 t = 12540 l = 30 t = 12410 l = 34 t = 11970 l = 45 t = 11679 l = 51 t = 9350 l = 85 t = 8910 l = 90 t = 7752 l = 102 t = 1224 l = 153 P = 17 t = 248740206 l = 3 t = 248740184 l = 7 t = 248740176 l = 8 t = 248739981 l = 21 t = 248739912 l = 24 t = 248738616 l = 56 t = 248726016 l = 168 t = 248457836 l = 751 t = 246201081 l = 2253 t = 240964616 l = 3943 t = 234919559 l = 5257 t = 230689176 l = 6008 t = 178771677 l = 11829 t = 124370106 l = 15771 t = 86298912 l = 18024 P = 15 t = 15736 l = 8 P = 1 t = 15768 l = 2 t = 15765 l = 3 t = 15750 l = 6 t = 15743 l = 7 t = 15666 l = 14 t = 15540 l = 21 t = 14868 l = 42 P = 7 t = 2227520 l = 8 t = 2157805 l = 373 t = 1112285 l = 1493 P = 3 t = 1490 l = 2 P = 1 t = 1456 l = 8 P = 1 t = 1282520 l = 8 t = 1282490 l = 11 t = 1278640 l = 88 t = 1277200 l = 103 t = 1242370 l = 283 t = 942656 l = 824 t = 640145 l = 1133 P = 7 t = 1130 l = 2 t = 1067 l = 11 t = 880 l = 22 P = 3 t = 1096 l = 8 P = 1 t = 13857000 l = 3 t = 13856996 l = 4 t = 13856928 l = 12 t = 13856853 l = 17 t = 13855680 l = 51 t = 13854660 l = 68 t = 13854305 l = 73 t = 13836096 l = 204 t = 13832916 l = 219 t = 13814228 l = 292 t = 13472880 l = 876 t = 13086345 l = 1241 t = 12124415 l = 1861 t = 6924780 l = 3723 t = 1533876 l = 4964 P = 15 t = 3720 l = 2 t = 3717 l = 3 t = 3702 l = 6 t = 3570 l = 17 t = 3128 l = 34 t = 2397 l = 51 t = 1022 l = 73 P = 7 t = 3712 l = 4 P = 1 t = 1465300 l = 4 t = 1465295 l = 5 t = 1465282 l = 7 t = 1465244 l = 11 t = 1465100 l = 20 t = 1464904 l = 28 t = 1464680 l = 35 t = 1464320 l = 44 t = 1463770 l = 55 t = 1462307 l = 77 t = 1457929 l = 121 t = 1455440 l = 140 t = 1450259 l = 173 t = 1441000 l = 220 t = 1417724 l = 308 t = 1391005 l = 385 t = 1347940 l = 484 t = 1281995 l = 605 t = 1225532 l = 692 t = 1106182 l = 847 t = 1090765 l = 865 t = 731444 l = 1211 t = 278740 l = 1540 P = 23 t = 1208 l = 2 t = 1183 l = 7 t = 1106 l = 14 P = 3 t = 1200 l = 4 t = 1195 l = 5 t = 1144 l = 11 t = 1000 l = 20 t = 220 l = 44 P = 5 t = 133529574 l = 3 t = 133529565 l = 5 t = 133529544 l = 8 t = 133529535 l = 9 t = 133529460 l = 15 t = 133529280 l = 24 t = 133529202 l = 27 t = 133528760 l = 40 t = 133528545 l = 45 t = 133526952 l = 72 t = 133523802 l = 107 t = 133522320 l = 120 t = 133520400 l = 135 t = 133506144 l = 216 t = 133477899 l = 321 t = 133464600 l = 360 t = 133386200 l = 535 t = 133162784 l = 856 t = 133065414 l = 963 t = 132945840 l = 1080 t = 132240765 l = 1605 t = 130858064 l = 2311 t = 130230984 l = 2568 t = 129354975 l = 2889 t = 124368240 l = 4280 t = 121935060 l = 4815 t = 109492869 l = 6933 t = 103849920 l = 7704 t = 66764790 l = 11555 t = 51090360 l = 12840 t = 29193345 l = 14445 P = 31 t = 11550 l = 3 t = 11520 l = 8 t = 11511 l = 9 t = 11256 l = 24 t = 11178 l = 27 t = 8928 l = 72 t = 5778 l = 107 P = 7 t = 11552 l = 2 t = 11540 l = 5 t = 11500 l = 10 P = 3 t = 83585296 l = 4 t = 83585278 l = 7 t = 83584900 l = 28 t = 83584445 l = 41 t = 83571776 l = 164 t = 83560330 l = 223 t = 83543978 l = 287 t = 83371775 l = 653 t = 83187028 l = 892 t = 82925780 l = 1148 t = 82366165 l = 1561 t = 80172728 l = 2612 t = 73136000 l = 4571 t = 64088416 l = 6244 t = 41783510 l = 9143 P = 15 t = 9140 l = 2 t = 8282 l = 41 t = 5740 l = 82 P = 3 t = 9132 l = 4 t = 9114 l = 7 t = 8736 l = 28 P = 3 t = 341861604 l = 3 t = 341861600 l = 4 t = 341861595 l = 5 t = 341861532 l = 12 t = 341861490 l = 15 t = 341861400 l = 20 t = 341860664 l = 43 t = 341859780 l = 60 t = 341853225 l = 129 t = 341846732 l = 172 t = 341838390 l = 215 t = 341728224 l = 516 t = 341653275 l = 645 t = 341491380 l = 860 t = 340151285 l = 1849 t = 338532120 l = 2580 t = 326474232 l = 5547 t = 322867244 l = 6163 t = 314507504 l = 7396 t = 299121975 l = 9245 t = 170930805 l = 18489 t = 95696844 l = 22188 t = 37988732 l = 24652 P = 23 t = 18480 l = 4 t = 18475 l = 5 t = ...

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!