I like this bit at the end:
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.
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
I like this bit at the end:
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.
Really makes you question your sanity when optimizing jumps in code without benchmarks.
Let's be real though, everything is IF statements all the way down
There's not a single thing in this universe that cannot be accomplished with enough IF statements... as long as you've got infinite time to wait
Could be easily made 50% space saving by only iffin all odds and return even on else. Maybe one if before to handle overflow to avoid wrong even if over the last if.
Yeah but then ALL even numbers would be slow to compute because you would have to chain through every odd before you know that 2
is even.
Depends on the expected distribution of input values
Well yeah, if you allow cheating!
Now we just need to someone to package it and upload it to NPM.
What's another 40 gb of node_modules anyway