Regular Expression for Prime Numbers (or How I came to fail at them, and love the bomb)
castironpi at gmail.com
castironpi at gmail.com
Thu Feb 14 12:35:23 EST 2008
On Feb 14, 5:26 am, bearophileH... at lycos.com wrote:
> cokofree:
>
> > 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.
> Bye,
> bearophile
all(x%i ha
More information about the Python-list
mailing list