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
```

My Personal Notes arrow_drop_up

Coder Machine Learner Social Activist Vocalist

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.