Hacker News new | ask | show | jobs
by the_real_cher 526 days ago
I like the algorithms that are the opposite of this where they try to find the slowest possible way to determine if a number is even.
2 comments

https://github.com/blackburn32/serverlessIsEven "A serverless implementation of isEven. Now you can know if your numbers are even, even at mass scale."
How about sending a packet back and forth to a server in another continent n times, and if it stops coming back, it was odd.
Better to use TCP, but I like your approach.
- Attempt to factor your integer n into primes...

- Once you have the complete prime factorization, check whether 2 is among its prime factors...

- If 2 is a factor, it’s even; if not, odd.

It's just 2 lines of code, therefore it's fast.

Also I only use the step over command in the debugger

There’s no upper limit, so there’d have to be some set of rules like no sleep(n).

Also given the halting problem, you could write an algorithm that would be impossible to determine if it loops forever.

If the results of TREE(n) had specific properties for even n, you could easily check by first calculating TREE(n) and then looking for those properties in the results. Might need a bignum library.