Friday, October 24, 2025
HomeLanguagesPython sympy | sieve.search() method

Python sympy | sieve.search() method

With the help of sympy.sieve.search() method, we can find the indices i, j of the primes that bound a given number. If the given number is prime then i == j.

Syntax: sieve.search(n)
Parameter:
n – It denotes the number whose bounding prime indices is found.

Returns: Returns a tuple containing the bounding prime indices of n.

Example #1:




# import sympy 
from sympy import sieve
  
# Use sieve.search() method 
i, j = sieve.search(23
      
print("The bounding prime indices of the number 23 : {}, {}".format(i, j))  


Output:

The bounding prime indices of the number 23 : 9, 9

Example #2:




# import sympy 
from sympy import sieve
  
# Use sieve.search() method 
i, j = sieve.search(25
      
print("The bounding prime indices of the number 23 : {}, {}".format(i, j))      


Output:

The bounding prime indices of the number 23 : 9, 10
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS