can anyone spot error in this solution

https://www.codechef.com/viewsolution/19963049

i did a lot of research but couldn’t find anything…

can anyone spot error in this solution

https://www.codechef.com/viewsolution/19963049

i did a lot of research but couldn’t find anything…

“`sqrt`

” is not a built-in function in Python. You have to import it, by adding at the top (for example):

```
from math import sqrt
```

`math`

is part of the Standard Library

This is a good problem to try out a sieve. You have a fixed space - up to a little over 2000 - where you want to know whether values are prime or not. So you can just make an array of truth values *once* using a sieve and check them instead of recalculating.

The idea is that you can just eliminate anything that is a multiple of each prime as you encounter them in succession. For example:

```
isPrime = [True]*2100
isPrime[1] = False
for c in range(2,2100):
if isPrime[c]:
for m in range(2*c, 2100, c):
isPrime[m] = False
```

There are ways to improve this also, but I wanted to make sure the concept was clear.