How to find if a number is odd or even?
In PHP I learn to use the MOD (%) operator. see below for an example:
$i = 10;
if ($i % 2) {
echo "$i is odd";
} else {
echo "$i is even";
}
You can also use the PHP "&" operator that will give you better
performance
You can use the PHP code like so:
$i = 10;
if ( $i&1 )
{
echo "$i is odd";
}
else
{
echo "$i is even";
}
NewSourceMedia is providing links to these listings as
a courtesy, and makes no representations regarding the content or
any information related thereto. Any questions, complaints or claims
regarding the downloaded content or details must be directed to the appropriate
publisher. We do not encourage or condone the use of any
software in violation of applicable laws.