在sympy.sieve.extend()方法的幫助下,我們可以使篩子覆蓋所有小於等於給定自然數的質數。
用法: sieve.extend(N)
參數:
N - It denotes the number up to which the sieve is extended.
返回: The function does not return anything.
範例1:
# import sympy
from sympy import sieve
# Use sieve.extend() method
sieve.extend(50)
prime_list = sieve._list
print("Prime Numbers up to 50 : {}".format(prime_list))
輸出:
Prime Numbers up to 50 : array('l', [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47])
範例2:
# import sympy
from sympy import sieve
# Use sieve.extend() method
sieve.extend(100)
prime_list = sieve._list
print("Prime Numbers up to 100 : {}".format(prime_list))
輸出:
Prime Numbers up to 100 : array('l', [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97])
相關用法
- Python sympy.rf()用法及代碼示例
- Python sympy.apart()用法及代碼示例
- Python sympy.cot()用法及代碼示例
- Python sympy.csc()用法及代碼示例
- Python sympy.tan()用法及代碼示例
- Python sympy.crt()用法及代碼示例
- Python sympy.apart()用法及代碼示例
- Python sympy.Add()用法及代碼示例
- Python sympy.lcm()用法及代碼示例
- Python sympy.gcd()用法及代碼示例
- Python sympy.S()用法及代碼示例
- Python sympy.ff()用法及代碼示例
- Python sympy.sin()用法及代碼示例
- Python sympy.Mod()用法及代碼示例
- Python sympy RGS用法及代碼示例
注:本文由純淨天空篩選整理自rupesh_rao大神的英文原創作品 Python sympy | sieve.extend() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。