Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's kind of ironic that the python generator script uses modulo. The author could have pushed it to the point of not using one.

I'm tempted to write a followup doing even crazier things...



I'm pretty sure that was an intentional joke. I do wish it'd have been a bitwise AND with 1.


Clearly the solution is to factor each number and to (recursively) test the parity of the sum of the factors. Since all prime numbers other than 2 are known to be odd, the parity test for the case of a single factor is easy. You only need to special-case 4 to avoid an infinite recursion.


Author should have perhaps bootstrapped a script that doesn't use modulo?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: