<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Comments on snippet: 'Prime number tester'</title>
    <description>Snipplr comments feed</description>
    <link>https://ipv6.snipplr.com/</link>
    <lastBuildDate>Tue, 07 Apr 2026 02:30:26 +0000</lastBuildDate>
    <item>
      <title>deepsoul said on 02/Aug/2009</title>
      <link>https://ipv6.snipplr.com/view/6713/prime-number-tester</link>
      <description>&lt;p&gt;The test works on unary notation, not decimal.  So 2 is written as "11", 3 as "111", 17 as "11111111111111111" and so on.  The first branch of the regex matches the empty string (representing 0) and "1" (representing 1), marking them as non-primes.  The second branch succeeds if and only if the unary number consists of two or more times two or more 1s, which means it is the product of these two numbers (both at least 2), so not a prime.  To print a string of primes and see that this works:&#13;
&#13;
    perl -l -e '(1 x $_) !~ /^1?$|^(11+?)\1+$/ & print while ++$_;'&#13;
&#13;
See also: http://www.catb.org/jargon/html/O/one-liner-wars.html&lt;/p&gt;</description>
      <pubDate>Sun, 02 Aug 2009 17:55:24 UTC</pubDate>
      <guid>https://ipv6.snipplr.com/view/6713/prime-number-tester</guid>
    </item>
  </channel>
</rss>
