function tf = is_it_odd(n)
if mod(n,2)==0
tf = 'false';
else
tf = 'ture';
end
why assertion failed. it works in matlab.
Thanks for your answer, you had a typo in true, also you should remove ' ' from false and true
Test | Status | Code Input and Output |
---|---|---|
1 | Fail |
n = 1;
ans_correct = true;
assert(isequal(is_it_odd(n),ans_correct))
|
2 | Fail |
n = 2;
ans_correct = false;
assert(isequal(is_it_odd(n),ans_correct))
|
3 | Fail |
n = 28;
ans_correct = false;
assert(isequal(is_it_odd(n),ans_correct))
|
4 | Fail |
n = 453;
ans_correct = true;
assert(isequal(is_it_odd(n),ans_correct))
|
5 | Fail |
n = 17;
ans_correct = true;
assert(isequal(is_it_odd(n),ans_correct))
|
6 | Fail |
n = 16;
ans_correct = false;
assert(isequal(is_it_odd(n),ans_correct))
|
1425 Solvers
middleAsColumn: Return all but first and last element as a column vector
387 Solvers
Compute a dot product of two vectors x and y
750 Solvers
We love vectorized solutions. Problem 1 : remove the row average.
546 Solvers
573 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!