Regular Expression for Prime Numbers (or How I came to fail at them, and love the bomb)

bearophileHUGS at bearophileHUGS at
Thu Feb 14 12:26:24 CET 2008

> Sadly that is pretty slow though...

It's quadratic, and it's not even short, you can do (quadratic still):

print [x for x in range(2, 100) if all(x%i for i in range(2, x))]

In D you can write similar code.

More information about the Python-list mailing list