📜  Python| sympy.compositepi() 方法

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

Python| sympy.compositepi() 方法

sympy.compositepi()方法的帮助下,我们可以找到小于或等于给定数的合数的个数。

示例 #1:

# import compositepi() method from sympy
from sympy import compositepi
  
n = 10
  
# Use compositepi() method 
count_composites = compositepi(n) 
      
print("The number of composites numbers less than or equal to {} is {}".format(n, count_composites))

输出:

The number of composites numbers less than or equal to 10 is 5

示例 #2:

# import compositepi() method from sympy
from sympy import compositepi
  
n = 100
  
# Use compositepi() method 
count_composites = compositepi(n) 
      
print("The number of composites numbers less than or equal to {} is {}".format(n, count_composites))          

输出:

The number of composites numbers less than or equal to 100 is 74