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

This is interesting - i thought it would be something complex, but really its just using the fundamental meaning of prime.

Literally what its doing is turn a number in to all 1s, if the number is 1 return true. Otherwise try all possible ways to put it into 2 or more equal groups, return true once we find one that works.

You don't get closer to the definition of "prime" than that.



If the number of 1's itself is prime, then n is prime. That's all this does. Search the other comments for 'hung' or 'hang' to see examples of small numbers that take forever to resolve.


Sure. its basically a less efficient form of trial division.




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

Search: