MATLAB: Number of odd numbers in an array

helpodd numbers

How to find the number of odd numbers in an array.
Example: function [N] = odd (A);.
I am only allowed to use one single variable for an output and an input.

Best Answer

function n = myNOdds(x)
n = sum(mod(x,2)==1);
end
Related Question