Where is my hammer?
sub isPrime($) { $n=pop; 1^(1x$n--)=~/^(1{2,$n})\1+$/; }
With n>2
Just for fun as a contrib to https://github.com/fxn/math-with-regexps/blob/master/one-liners.sh (fxn).
Update, thanks to ambrus's reply: Re^2: is it prime?
sub isPrime($) { (1x pop)!~/^(11+)\1+$/ }
In reply to Re: is it prime?
by brx
in thread is it prime?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |