Seems to me that the "best" answer would be tf = logical(mod(n,2)). But I guess the description does not explicitly require logicals, so maybe I am reading too much into the problem. Using logical makes the solution 17 compared to 13 without.
by calling logical function you add extra code.
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%%
n = 1;
ans_correct = true;
assert(isequal(is_it_odd(n),ans_correct))
|
2 | Pass |
%%
n = 2;
ans_correct = false;
assert(isequal(is_it_odd(n),ans_correct))
|
3 | Pass |
%%
n = 28;
ans_correct = false;
assert(isequal(is_it_odd(n),ans_correct))
|
4 | Pass |
%%
n = 453;
ans_correct = true;
assert(isequal(is_it_odd(n),ans_correct))
|
5 | Pass |
%%
n = 17;
ans_correct = true;
assert(isequal(is_it_odd(n),ans_correct))
|
6 | Pass |
%%
n = 16;
ans_correct = false;
assert(isequal(is_it_odd(n),ans_correct))
|
Find all elements less than 0 or greater than 10 and replace them with NaN
13051 Solvers
Remove all the words that end with "ain"
1292 Solvers
2500 Solvers
Find state names that end with the letter A
708 Solvers
347 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!