Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
vs = find_psmooth(2,16);
assert(isequal(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]))
|
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]))
|
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)
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)
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)
ans =
231
|
785 Solvers
1961 Solvers
Predicting life and death of a memory-less light bulb
277 Solvers
Sums of Multiple Pairs of Triangular Numbers
203 Solvers
Tick. Tock. Tick. Tock. Tick. Tock. Tick. Tock. Tick. Tock.
761 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!