Here are the news:

I could fix the false positives primes just adding

+1 as follows:

- Code: Select all
`def isprime(x):`

return all(x % i for i in xrange(2, int(math.sqrt(x)) + 1))

Then, I was thinking about the Big O, and I noticed that the growth rate of a

logarithm is lower than the

square root, so I tried these things:

- Code: Select all
`def isprime(x):`

return all(x % i for i in range(2, int(math.log(x, 2)) + 2))

for x in xrange(2, int(math.sqrt(N))):

if isprime(x):

primos.append(x)

(

N and

primos are declared before)

And we have:

- Code: Select all
`len(primos)`

135888

And it works properly unless the fact that it does not start at

2, and the fact that number

49 is there, but maybe it could be fixed with something as we did last time(in addition to 49, it is very probable there are more "intruders"):

- Code: Select all
`primos[:30]`

[3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113]

Then, I tried another option:

- Code: Select all
`def isprime(x):`

return all(x % i for i in range(2, int(math.log(x, 2)) + 2))

for x in xrange(2, int(math.log(N, 2))):

if isprime(x):

primos.append(x)

But this time, the result it:

- Code: Select all
`len(primos)`

11

so just:

- Code: Select all
`primos[:30]`

[3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]

Finally, I also tried:

- Code: Select all
`def isprime(x):`

return all(x % i for i in xrange(2, int(math.sqrt(x)) + 1))

for x in xrange(2, int(math.log(N, 2))):

if isprime(x):

primos.append(x)

with:

- Code: Select all
`len(primos)`

12

and:

- Code: Select all
`primos`

[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]

So, after these 3 options, I reached a conclusion with 2 possible points of view:

1) Only the first case is the efficent one, so using

log at both places is not a good idea because it makes it so tiny.

2) Maybe second or third case could be ok if the

base of the log is a different one, or we do any other kind of improvement.

In any case, I still having the problem of not using the

log properly (remember the little mistake we noticed in the first option).

Right now, I would use

sqrt because it works fine, but it is true that

log could be even better, so it could be great if I can improve its use.

I would be pleased to listen to your opinion as usual.