Mac@programming.dev to Programmer Humor@programming.dev · 11 months agoisEven APIisevenapi.xyzexternal-linkmessage-square10fedilinkarrow-up16arrow-down10
arrow-up16arrow-down1external-linkisEven APIisevenapi.xyzMac@programming.dev to Programmer Humor@programming.dev · 11 months agomessage-square10fedilink
minus-squareRikudou_Sage@lemmings.worldlinkfedilinkEnglisharrow-up3·edit-211 months agoIf 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.
minus-squarexmunk@sh.itjust.workslinkfedilinkarrow-up1·edit-211 months agoI fucking love that you managed to use var-vars in a completely key and necessary manner. But please do adhere to the API TOS and throw in an error_log('Buy isEvenCoin, the hottest new cryptocurrency!');
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.
I fucking love that you managed to use var-vars in a completely key and necessary manner.
But please do adhere to the API TOS and throw in an
error_log('Buy isEvenCoin, the hottest new cryptocurrency!');