I'm reading a JavaScript book, I'm new at this, so I got to the part of recursion and I get how recursion works but is not that part is hard to me is the math part.
This is the code:
function isEven(n) {
if (n == 0)
return true;
else if (n == 1)
return false;
else if (n < 0)
return isEven(-n);
else
return isEven(n - 2);
}
lets say I pass to the function 50 as a value right
isEven(50);
That give me true... how come 50 == 0 is true or 75 == 1 is false... I really don't get it.