Cody

Solution 835298

Submitted on 22 Feb 2016 by Guillaume
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
%% vs = find_psmooth(2,16); assert(isequal(vs,[1 2 4 8 16]))

vs = 1 2 4 8 16

2   Pass
%% vs = find_psmooth(3,128); assert(isequal(vs,[1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 54, 64, 72, 81, 96, 108, 128]))

vs = Columns 1 through 16 1 2 3 4 6 8 9 12 16 18 24 27 32 36 48 54 Columns 17 through 22 64 72 81 96 108 128

3   Pass
%% vs = find_psmooth(11,73); assert(isequal(vs,[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 27, 28, 30, 32, 33, 35, 36, 40, 42, 44, 45, 48, 49, 50, 54, 55, 56, 60, 63, 64, 66, 70, 72]))

vs = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 18 Columns 17 through 32 20 21 22 24 25 27 28 30 32 33 35 36 40 42 44 45 Columns 33 through 44 48 49 50 54 55 56 60 63 64 66 70 72

4   Pass
%% pmax=7; vmax=120; vs = find_psmooth(pmax,vmax); vs=unique(vs); % Validity checks vs(vs>vmax)=[]; vs(vs<1)=[]; vs=floor(vs); length(vs) if length(vs)==50 % Known length pass=true; else pass=false; end pv=primes(vmax); pv(pv<=pmax)=[]; for i=pv if any(mod(vs,i)==0) % check for prime divisors >pmax pass=false; break; end end assert(pass)

vs = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 12 14 15 16 18 20 Columns 17 through 32 21 24 25 27 28 30 32 35 36 40 42 45 48 49 50 54 Columns 33 through 48 56 60 63 64 70 72 75 80 81 84 90 96 98 100 105 108 Columns 49 through 50 112 120 ans = 50

5   Pass
%% pmax=11; vmax=300; vs = find_psmooth(pmax,vmax); vs=unique(vs); % Validity checks vs(vs>vmax)=[]; vs(vs<1)=[]; vs=floor(vs); length(vs) if length(vs)==104 % Known length pass=true; else pass=false; end pv=primes(vmax); pv(pv<=pmax)=[]; for i=pv if any(mod(vs,i)==0) % check for prime divisors >pmax pass=false; break; end end assert(pass)

vs = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 18 Columns 17 through 32 20 21 22 24 25 27 28 30 32 33 35 36 40 42 44 45 Columns 33 through 48 48 49 50 54 55 56 60 63 64 66 70 72 75 77 80 81 Columns 49 through 64 84 88 90 96 98 99 100 105 108 110 112 120 121 125 126 128 Columns 65 through 80 132 135 140 144 147 150 154 160 162 165 168 175 176 180 189 192 Columns 81 through 96 196 198 200 210 216 220 224 225 231 240 242 243 245 250 252 256 Columns 97 through 104 264 270 275 280 288 294 297 300 ans = 104

6   Pass
%% pmax=13; vmax=900; vs = find_psmooth(pmax,vmax); vs=unique(vs); % Validity checks vs(vs>vmax)=[]; vs(vs<1)=[]; vs=floor(vs); length(vs) if length(vs)==231% Known length pass=true; else pass=false; end pv=primes(vmax); pv(pv<=pmax)=[]; for i=pv if any(mod(vs,i)==0) % check for prime divisors >pmax pass=false; break; end end assert(pass)

vs = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 18 20 21 22 24 25 26 27 28 30 32 33 35 36 39 40 Columns 33 through 48 42 44 45 48 49 50 52 54 55 56 60 63 64 65 66 70 Columns 49 through 64 72 75 77 78 80 81 84 88 90 91 96 98 99 100 104 105 Columns 65 through 80 108 110 112 117 120 121 125 126 128 130 132 135 140 143 144 147 Columns 81 through 96 150 154 156 160 162 165 168 169 175 176 180 182 189 192 195 196 Columns 97 through 112 198 200 208 210 216 220 224 225 231 234 240 242 243 245 250 252 Columns 113 through 128 256 260 264 270 273 275 280 286 288 294 297 300 308 312 315 320 Columns 129 through 144 324 325 330 336 338 343 350 351 352 360 363 364 375 378 384 385 Columns 145 through 160 390 392 396 400 405 416 420 429 432 440 441 448 450 455 462 468 Columns 161 through 176 480 484 486 490 495 500 504 507 512 520 525 528 539 540 546 550 Columns 177 through 192 560 567 572 576 585 588 594 600 605 616 624 625 630 637 640 648 Columns 193 through 208 650 660 672 675 676 686 693 700 702 704 715 720 726 728 729 735 Columns 209 through 224 750 756 768 770 780 784 792 800 810 819 825 832 840 845 847 858 Columns 225 through 231 864 875 880 882 891 896 900 ans = 231

Suggested Problems