More correctly, it generates a list of numbers less than n, then removes all numbers from that list that aren't prime. Also, it breaks if n < 3. Its definately an interesting implementation. I'm not sure I like the 'y' variable. Stephen. Dethe Elza wrote:
Well, it seems to generate primes less than n, but breaks if n < 2 (perhaps it should return an empty list?)
Another entry for obfuscated python... %-)
--Dethe
On 28-Jan-04, at 2:33 PM, Gregor Lingl wrote:
def what(n): x,y = range(n), [0]*n x[1]= 0 z = 0 while z*z <= n: z+=1 if x[z]: x[z*z:n:z]=y[z*z:n:z] return [z for z in x if z]
This past week, everyday when I opened my Wall Street Journal, I was met with a full page ad from Microsoft. This ad was dominated by three simple words "Protect your PC." This strikes me as something akin to the Saudi government running ads in the New York Times in mid-September of 2001 saying "Protect your Tall Buildings." --Russ McGuire
------------------------------------------------------------------------
_______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig