4 ms·
Perl's regex engine is really fast, so presumably: perl -lne '(1x$_) =~ /^1?$|^(11+?)\1+$/ || print "$_ is prime"'
by peteretep 7y ago
Perl's regex engine is really fast, so presumably:
perl -lne '(1x$_) =~ /^1?$|^(11+?)\1+$/ || print "$_ is prime"'
- saagarjha 7y agoFor the curious: https://www.pixelstech.net/article/1324906920-A-Perl-Regular-Expression-That-Matches-Prime-Numbers https://www.pixelstech.net/article/1324906920-A-Perl-Regular...