Sieve of Eratosthenes as a Regexp

No, really.

sub is_prime { ('1' x shift) !~ /^1?$|^(11+?)\1+$/) }

Leave a Reply

You must be logged in to post a comment.