Hello
General
Toys
compression
genea
look and say
quines
rat
robump
self-similar
song history
string synth
stroids
tm interpreter
genea
look and say
quines
rat
robump
self-similar
song history
string synth
stroids
tm interpreter
Other
Blog Archives
Super Links
Copyleft
Unless otherwise stated, all original content on this site is licensed under your choice of the GNU FDL or the Creative Commons ShareAlike License.
Validate
Hopefully, this website is valid. You can check the XHTML, the CSS, and the RSS.
Stats
PRIMES is Decided by a (Perl) Regular Expression!
I've been informed of an extremely clever primality test implemented as a perl regular expression. Try it yourself:
perl -e 'print "$num is prime.\n" if (1 x ($num = shift)) !~ /^(11+)\1+$/' 19
perl -e 'print "$num is prime.\n" if (1 x ($num = shift)) !~ /^(11+)\1+$/' 21
It is horribly exponential and segfaults perl 5.8.0 on my system if you give it a large number. Nevertheless, it is really cool. It works by representing the number in unary, then seeing if it can be divided into two or more equal groups of two or more characters.