4 ms·
I'm afraid I take issue with the phrase "amazingly performant". I would struggle to come up with another way of determining whether a number near 2^32 is even t
by timrobinson333 3y ago
I'm afraid I take issue with the phrase "amazingly performant". I would struggle to come up with another way of determining whether a number near 2^32 is even that takes anything like 10 seconds
- christophilus 3y agoI'd bet this is slower: function isEven(n) { let arr = []; let sign = -1; for (let i = 0; i < Math.abs(n); ++i) { arr = [...arr, sign]; sign *= -1; } return arr.length === 0 || arr.reduce((a, b) => a + b) === 0; } But I'm not going to test it, because I'm doing productive things on my computer right now, and don't want to OOM. Sadly, the OP missed an opportunity to call his program "blazingly fast" [0]. [0] https://www.youtube.com/results?search_query=primagen+blazingly+fast https://www.youtube.com/results?search_query=primagen+blazin...