#### Re: Re: problems from the headhunter

Hello, Kodt, you wrote: About I do not know. run (eratosphen) # 0.692999839783 run (populate1) # 4.71099996567 run (populate2) # 3.72500014305 This slow sieve, here hardly faster: def eratosphen2 (n): isc = [False] * (n+1) for x in xrange (3, n+1,2): if isc [x]: continue if n / x <x: break for y in xrange (x*x, n+1, x+x): isc [y] = True return [2] + [x for x in xrange (3, n+1,2) if not isc [x]] sifting of even numbers, sifting of already sifted small numbers, and empty sifting on too big prime numbers Is thrown out. At me (on ) for N=2400000 it is laid down in 0.15 seconds, for N=24000000 - in 2 seconds, at you it should turn out 0.17 and 2.3 accordingly. Still not one hundred, but already hardly is better Still it is possible to accelerate, if under even numbers not to select storage, plus to alter an array with on the numerical: def eratosphen3 (n): m = (n+1)//2 isc = [0] *m for x in xrange (1, m): if isc [x]: continue p, b = x + x + 1, (x + x) * (x + 1) if m <= b: break for y in xrange (b, m, p): isc [y] = 1 return [2] + [x+x+1 for x in xrange (1, m) if not isc [x]] So at me it was accelerated till 0.12 and 1.66 accordingly.