IsOdd
Returns true if the given number is odd, false otherwise.
- Check whether a number is odd or even using the modulo (
%) operator. - Return
trueif the number is odd,falseif the number is even.
public static partial class _30s
{
public static bool IsOdd(int n)
{
return n % 2 != 0;
}
}_30s.IsOdd(3); // true
_30s.IsOdd(4); // false