Skip to main content
4 of 4
Added named reference
ilmale
  • 1.1k
  • 6
  • 12

PERL 53 54 52 48

('a'x($_=pop))=~/^a?$|^(?<a>aa+?)\g{a}+$/||print

Thanks to reddit: http://www.reddit.com/r/programming/comments/crmhe/regular_expression_to_check_for_prime_numbers_1111/

ilmale
  • 1.1k
  • 6
  • 12