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