in reply to Primes. Again.
Another way of testing for primes is to use the prime regex. (For small numbers at least, it can exceed the recursion limit pretty quickly for larger numbers.)
use strict; use warnings; sub prime{ (1 x shift) !~ /^1?$|^(11+?)\1+$/; } for (1..1000){ print "$_\n" if prime $_; }
|
|---|