Fun with primality testing

François Pinard pinard at
Fri May 12 19:16:51 EDT 2000

Hi, people.

For your mere enjoyment!  Here is Python code which prints primes below 1000.
At the local Perl mongers meeting, someone showed this nicety to me.

import re
for n in range(2, 1000):
    if not re.match('(11+)\\1+$', '1'*n):
        print n

François Pinard

More information about the Python-list mailing list