[ProgSoc] The magic of regex

Peter Dolkens peter.dolkens at ddrit.com
Thu Nov 19 00:36:02 EST 2009


Something I found the other day, some people seem to be under the impression
that you guys would enjoy it, so here goes.

Take a number, generate a string that contains that many "1"s

Match it against the following regex:

/^1?$|^(11+?)\1+$/

If it fails to match, you sir (or madam), have yourself a PRIME number.

Enjoy :)

That Guy (AKA Milky)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://progsoc.org/pipermail/progsoc/attachments/20091119/ccd41a69/attachment.htm 


More information about the Progsoc mailing list