Question: I'm trying to disable the checkbox for specific field on the base of condition,

```
if (value == 3)
ko.observable(value);

```

Answer: 
I decided to play with this and created a further optimized NumPy version posted by *@user2357112 supports Monica* that uses the Numba JIT to speed things up.

```
import numba
import numpy
import timeit
import datetime 

@numba.jit(nopython = True, parallel = True, fastmath = True, forceobj = False)
def sieve (n: int) -> numpy.ndarray:
    primes = numpy.full(n, True)
    primes[0], primes[1] = False, False
    for i in numba.prange(2, int(numpy.sqrt(n) + 1)):
        if primes[i]:
            primes[i*i::i] = False
    return numpy.flatnonzero(primes)

if __name__ == "__main__":

    timestart = timeit.default_timer()
    print(sieve(1000000000))
    timestop = timeit.default_timer()
    timedelta = (timestop - timestart)
    print(f"Time Elapsed: {datetime.timedelta(seconds = timedelta)}")

else:
    pass

```

On my laptop, I sieve out the primes in the first 1 billion (`1e9`) natural numbers in `0:00:10.378686` seconds. The JIT provides at least an order of magnitude of performance here; the next fastest answer at the time of writing took `0:01:27.059963` minutes. Sadly, I don't have an Nvidia GPU and Cuda on this system (Mac), otherwise I'd have used that.
Here's a simple way to do this using NumPy. It is somewhat similar to the OP's idea of indexing instead of looping again inside the main loop, but without the division check, only slicing.

It is also similar to user2357112 supports Monica answer, but this one only considers odd numbers, which makes it faster.

This is a typical odd only sieve: <https://stackoverflow.com/a/20248491/8094047>.

1. Create a bool array of size n.
2. Loop through odd numbers up to square root of n.  
Note: numbers are used interchangeably as indices
3. Mark composite (multiples of primes) numbers as false.

In the end we have a bool array that we can use to check if a number below n is prime (except even numbers, you can check for them without the array, using & 1 or so)

Avg. time for n = 20000000: 0.1063s

```py
import numpy as np
n = 20000000

isprime = np.ones(n, dtype=np.bool)

# odd only sieve
i = 3
while (i * i < n):
    if isprime[i]:
        isprime[i * i:n:2 * i] = False
    i += 2

# test
print(isprime[97]) # should be True

```