logoalt Hacker News

4 billion if statements (2023)

636 pointsby damethos12/06/2025176 commentsview on HN

Comments

ks2048last Friday at 2:06 PM

Silly. Don't waste your time on problems other people have already solved! Use JS and "npm install odd_or_even".

Exumalast Friday at 5:05 PM

This is good stuff

pcthrowawaylast Friday at 11:35 PM

> As a side note, the program is amazingly performant. For small numbers the results are instantaneous and for the large number close to the 2^32 limit the result is still returned in around 10 seconds.

Lol

tornadofartlast Friday at 1:25 PM

"The executable is around 2 MB"- Every dotnet programmer: "Those are rookie numbers!"

nmilolast Friday at 2:21 PM

I see why now npm's is-odd has millions of downloads

ajsnigrutinlast Friday at 1:56 PM

Why not optimize this? Create a lookup table, a 2^64 large array of bools, and just check the n-th element to see if it's odd or even?

Many gigabytes saved!

/s

ITniggahlast Friday at 8:43 PM

[flagged]

d-lisplast Friday at 11:09 AM

if(n&1)

else

show 1 reply