News for hackers. Stuff that matters.
Re:Regular Expression That Checks If A Number Is Prime by fxn on Friday September 09, 2016 @09:43AM (#12462084)
This regexp is totally brilliant. It solves this problem in an unexpected way, because you think numbers, but the solution thinks strings. Not only that, the paradox, or its beauty, is that it goes to the root of the number abstraction: counting sticks.

I explored this technique some years later to solve a bunch of other problems, coprimality, prime factorization, Euler's phi, continued fractions, etc. (see https://github.com/fxn/math-with-regexps/blob/master/one-lin...).

There are no comments on this comment yet.