Incoming trademark lawsuit from iSeven, the API that tells you if a number is seven or not
If anyone wants a more efficient local version for php:
function isEven(int $number): bool
{
${1} = false;
${2} = true;
while ($number > 2) {
$number -= 2;
}
return $$number;
}
Edit: Now with support for large numbers!
function isEven(int|string $number): bool
{
${1} = false;
${2} = true;
while (bccomp($number, 2) === 1) {
$number = bcsub($number, 2);
}
$number = (int) $number;
return $$number;
}
Edit 2: someone asked for an ad-supported version, here you go!
function isEven(int|string $number): bool
{
${1} = false;
${2} = true;
while (bccomp($number, 2) === 1) {
error_log('Buy isEvenCoin, the hottest new cryptocurrency!');
$number = bcsub($number, 2);
}
$number = (int) $number;
return $$number;
}
Side note, no more suggestions please, this is getting quite long.
Oh, bummer, my number isn’t supported by the free version:
https://api.isevenapi.xyz/api/iseven/8764389587485736749956772984692357867345989845699872561/
Just divide that number by two until it’s small enough to make the request under the free version.
Easy workaround, just test the last digit. If it is even, the entire number is even, else odd.
Only way it could be better is if they threw “AI” in there somewhere.
im glad that people are out there building the web services we truly need.