(self, n)
Grow the sieve to cover all primes <= n (a real number).

        Examples
        ========

        >>> from sympy import sieve
        >>> from array import array # this line and next for doctest only
        >>> sieve._list = array('l', [2, 3, 5, 7, 11, 13])

        >>> sieve.extend(30)
        >>> sieve[10] == 29
        True
Grow the sieve to cover all primes <= n (a real number).
Grow the sieve to cover all primes < = n ( a real number ) .
def extend(self, n):
        """Grow the sieve to cover all primes <= n (a real number).

        Examples
        ========

        >>> from sympy import sieve
        >>> from array import array # this line and next for doctest only
        >>> sieve._list = array('l', [2, 3, 5, 7, 11, 13])

        >>> sieve.extend(30)
        >>> sieve[10] == 29
        True
        """
        n = int(n)
        if n <= self._list[-1]:
            return

        # We need to sieve against all bases up to sqrt(n).
        # This is a recursive call that will do nothing if there are enough
        # known bases already.
        maxbase = int(n**0.5) + 1
        self.extend(maxbase)

        # Create a new sieve starting from sqrt(n)
        begin = self._list[-1] + 1
        newsieve = _arange(begin, n + 1)

        # Now eliminate all multiples of primes in [2, sqrt(n)]
        for p in self.primerange(2, maxbase):
            # Start counting at a multiple of p, offsetting
            # the index to account for the new sieve's base index
            startindex = (-begin) % p
            for i in xrange(startindex, len(newsieve), p):
                newsieve[i] = 0

        # Merge the sieves
        self._list += _array('l', [x for x in newsieve if x])
def extend ( self , n ) : n = int ( n ) if n <= self . _list [ - 1 ] : return # We need to sieve against all bases up to sqrt(n). # This is a recursive call that will do nothing if there are enough # known bases already. maxbase = int ( n ** 0.5 ) + 1 self . extend ( maxbase ) # Create a new sieve starting from sqrt(n) begin = self . _list [ - 1 ] + 1 newsieve = _arange ( begin , n + 1 ) # Now eliminate all multiples of primes in [2, sqrt(n)] for p in self . primerange ( 2 , maxbase ) : # Start counting at a multiple of p, offsetting # the index to account for the new sieve's base index startindex = ( - begin ) % p for i in xrange ( startindex , len ( newsieve ) , p ) : newsieve [ i ] = 0 # Merge the sieves self . _list += _array ( 'l' , [ x for x in newsieve if x ] )