本文整理汇总了Python中sympy.Sieve.extend方法的典型用法代码示例。如果您正苦于以下问题:Python Sieve.extend方法的具体用法?Python Sieve.extend怎么用?Python Sieve.extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.Sieve
的用法示例。
在下文中一共展示了Sieve.extend方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_isprime
# 需要导入模块: from sympy import Sieve [as 别名]
# 或者: from sympy.Sieve import extend [as 别名]
def test_isprime():
s = Sieve()
s.extend(100000)
ps = set(s.primerange(2, 100001))
for n in range(100001):
# if (n in ps) != isprime(n): print n
assert (n in ps) == isprime(n)
assert isprime(179424673)
# Some Mersenne primes
assert isprime(2**61 - 1)
assert isprime(2**89 - 1)
assert isprime(2**607 - 1)
assert not isprime(2**601 - 1)
#Arnault's number
assert isprime(int('''
803837457453639491257079614341942108138837688287558145837488917522297\
427376533365218650233616396004545791504202360320876656996676098728404\
396540823292873879185086916685732826776177102938969773947016708230428\
687109997439976544144845341155872450633409279022275296229414984230688\
1685404326457534018329786111298960644845216191652872597534901'''))
# pseudoprime that passes the base set [2, 3, 7, 61, 24251]
assert not isprime(9188353522314541)
assert _mr_safe_helper(
"if n < 170584961: return mr(n, [350, 3958281543])") == \
' # [350, 3958281543] stot = 1 clear [2, 3, 5, 7, 29, 67, 679067]'
assert _mr_safe_helper(
"if n < 3474749660383: return mr(n, [2, 3, 5, 7, 11, 13])") == \
' # [2, 3, 5, 7, 11, 13] stot = 7 clear == bases'
示例2: test_isprime
# 需要导入模块: from sympy import Sieve [as 别名]
# 或者: from sympy.Sieve import extend [as 别名]
def test_isprime():
s = Sieve()
s.extend(100000)
ps = set(s.primerange(2, 100001))
for n in range(100001):
assert (n in ps) == isprime(n)
assert isprime(179424673)
# Some Mersenne primes
assert isprime(2**61 - 1)
assert isprime(2**89 - 1)
assert isprime(2**607 - 1)
assert not isprime(2**601 - 1)
示例3: test_isprime
# 需要导入模块: from sympy import Sieve [as 别名]
# 或者: from sympy.Sieve import extend [as 别名]
def test_isprime():
s = Sieve()
s.extend(100000)
ps = set(s.primerange(2, 100001))
for n in range(100001):
assert (n in ps) == isprime(n)
assert isprime(179424673)
# Some Mersenne primes
assert isprime(2**61 - 1)
assert isprime(2**89 - 1)
assert isprime(2**607 - 1)
assert not isprime(2**601 - 1)
#Arnault's number
assert isprime(int('''
803837457453639491257079614341942108138837688287558145837488917522297\
427376533365218650233616396004545791504202360320876656996676098728404\
396540823292873879185086916685732826776177102938969773947016708230428\
687109997439976544144845341155872450633409279022275296229414984230688\
1685404326457534018329786111298960644845216191652872597534901'''))
# pseudoprime that passes the base set [2, 3, 7, 61, 24251]
assert not isprime(9188353522314541)