It seems to provide the desired solution. Could anyone tell me why this is an incorrect solution?
The output should be logical,and it should't be char type:
function tf = is_it_odd(n)
x = n/2;
y = floor(x);
if x == y
tf = false;
else
tf = true;
end
end
good job
good solution
Test | Status | Code Input and Output |
---|---|---|
1 | Fail |
%%
n = 1;
ans_correct = true;
assert(isequal(is_it_odd(n),ans_correct))
true
|
2 | Fail |
%%
n = 2;
ans_correct = false;
assert(isequal(is_it_odd(n),ans_correct))
false
|
3 | Fail |
%%
n = 28;
ans_correct = false;
assert(isequal(is_it_odd(n),ans_correct))
false
|
4 | Fail |
%%
n = 453;
ans_correct = true;
assert(isequal(is_it_odd(n),ans_correct))
true
|
5 | Fail |
%%
n = 17;
ans_correct = true;
assert(isequal(is_it_odd(n),ans_correct))
true
|
6 | Fail |
%%
n = 16;
ans_correct = false;
assert(isequal(is_it_odd(n),ans_correct))
false
|
14194 Solvers
Celsius to Fahrenheit converter
280 Solvers
402 Solvers
403 Solvers
Write c^3 as sum of two squares a^2+b^2
243 Solvers