There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

isevenapi.xyz

eluvatar , (edited ) to programmer_humor in isEven API

The errors are great api.isevenapi.xyz/api/iseven/1.5

~~Sadly it’s not always accurate api.isevenapi.xyz/api/iseven/0~~ Edit: nevermind I’m an idiot

It’s also greatly lacking in number support api.isevenapi.xyz/api/iseven/one

huf ,

zero is even, so i dont see how that one’s wrong

eluvatar ,

Oh you’re right, I’m not sure what I was Ln thinking

xmunk ,

Is even states that it only returns true for even, passing in an odd number is technically unsupported.

megaman , to programmer_humor in isEven API

Funny as hell

morrowind , to programmer_humor in isEven API

I resent that there is a ruby developer included in there. isEven is not idiomatic naming. You should be using #even? from the standard library

fckreddit ,

Sorry sir, most JS developers don’t use standard library functions. We just use npm packages wherever possible.

jubilationtcornpone , to programmer_humor in isEven API

Only way it could be better is if they threw “AI” in there somewhere.

jol ,

With the new AI integration, you can get smart isEven results that return the correct answer 90% of the time and a more creative solution 20% of the time.

rem26_art , to programmer_humor in isEven API
@rem26_art@kbin.social avatar

im glad that people are out there building the web services we truly need.

rikudou , (edited ) to programmer_humor in isEven API

If anyone wants a more efficient local version for php:


<span style="color:#323232;">function isEven(int $number): bool
</span><span style="color:#323232;">{
</span><span style="color:#323232;">    ${1} = false;
</span><span style="color:#323232;">    ${2} = true;
</span><span style="color:#323232;">
</span><span style="color:#323232;">    while ($number > 2) {
</span><span style="color:#323232;">        $number -= 2;
</span><span style="color:#323232;">    }
</span><span style="color:#323232;">
</span><span style="color:#323232;">    return $$number;
</span><span style="color:#323232;">}
</span>

Edit: Now with support for large numbers!


<span style="color:#323232;">function isEven(int|string $number): bool
</span><span style="color:#323232;">{
</span><span style="color:#323232;">    ${1} = false;
</span><span style="color:#323232;">    ${2} = true;
</span><span style="color:#323232;">
</span><span style="color:#323232;">    while (bccomp($number, 2) === 1) {
</span><span style="color:#323232;">        $number = bcsub($number, 2);
</span><span style="color:#323232;">    }
</span><span style="color:#323232;">
</span><span style="color:#323232;">    $number = (int) $number;
</span><span style="color:#323232;">    return $$number;
</span><span style="color:#323232;">}
</span>

Edit 2: someone asked for an ad-supported version, here you go!


<span style="color:#323232;">function isEven(int|string $number): bool
</span><span style="color:#323232;">{
</span><span style="color:#323232;">    ${1} = false;
</span><span style="color:#323232;">    ${2} = true;
</span><span style="color:#323232;">
</span><span style="color:#323232;">    while (bccomp($number, 2) === 1) {
</span><span style="color:#323232;">        error_log('Buy isEvenCoin, the hottest new cryptocurrency!');
</span><span style="color:#323232;">        $number = bcsub($number, 2);
</span><span style="color:#323232;">    }
</span><span style="color:#323232;">
</span><span style="color:#323232;">    $number = (int) $number;
</span><span style="color:#323232;">    return $$number;
</span><span style="color:#323232;">}
</span>

Side note, no more suggestions please, this is getting quite long.

idunnololz ,
@idunnololz@lemmy.world avatar

This looks pretty inefficient. You should manually unroll that loop to improve performance.

shotgun_crab ,

Comment edits are the best version control system

rikudou ,

I agree! Added new commit to my comment.

xmunk ,

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!’);

CannotSleep420 , to programmer_humor in isEven API

What the fuck is a modulo? Is it some kind of npm package?

lud ,

Yes

generic ,
@generic@iusearchlinux.fyi avatar

Just Monika Modulo

56_ ,
@56_@lemmy.ml avatar

return (n % d + d) % d;

?

marcos , to programmer_humor in isEven API

Oh, bummer, my number isn’t supported by the free version:

api.isevenapi.xyz/…/87643895874857367499567729846…

captainjaneway ,
@captainjaneway@lemmy.world avatar

Just divide that number by two until it’s small enough to make the request under the free version.

taaz ,

pretty sure that has to be against their TOS

/s

mormegil ,
@mormegil@programming.dev avatar

That’s against the terms of math :-)

aaaa ,

That’s not even supported by the enterprise version. You’re going to need a special agreement with the iseven people to support numbers like that

fckreddit ,

Easy workaround, just test the last digit. If it is even, the entire number is even, else odd.

marcos ,

That’s preposterous! Next time you’ll tell me the language I’m using has a builtin operator that test if a number can be divided by another!

4am , to programmer_humor in isEven API

Incoming trademark lawsuit from iSeven, the API that tells you if a number is seven or not

ryry1985 , to programmer_humor in isEven API

I love that it works and the ads are pretty good.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • lifeLocal
  • goranko
  • All magazines