借助於sympy.compositepi()方法,我們可以找到小於或等於給定數字的複合數字。
用法: compositepi(n)
參數:
n – 它表示要計算的合成數量計數的數量。
返回值:返回小於或等於n的複合數字的數量。
示例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
相關用法
- Python next()用法及代碼示例
- Python os.dup()用法及代碼示例
- Python set()用法及代碼示例
- Python os.abort()用法及代碼示例
- Python os.WEXITSTATUS()用法及代碼示例
- Python os.fchmod()用法及代碼示例
- Python PIL getpixel()用法及代碼示例
- Python PIL putpixel()用法及代碼示例
- Python os.sysconf()用法及代碼示例
- Python os.confstr()用法及代碼示例
- Python os._exit()用法及代碼示例
- Python cmath.log()用法及代碼示例
- Python Tensorflow cos()用法及代碼示例
- Python sympy.rf()用法及代碼示例
注:本文由純淨天空篩選整理自rupesh_rao大神的英文原創作品 Python | sympy.compositepi() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。