📜  Python同情 | sieve.search() 方法

📅  最后修改于: 2022-05-13 01:54:42.675000             🧑  作者: Mango

Python同情 | sieve.search() 方法

sympy.sieve.search()方法的帮助下,我们可以找到限制给定数字的素数的索引i、j 。如果给定的数字是素数,则i == j

示例 #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))  

输出:

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

示例 #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))      

输出:

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