recipe-572196.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:code 作者: ActiveState 项目源码 文件源码
def getPrime(b,seed):
    #Generates an integer of b bits that is probably prime
    #written by Josiah Carlson
    #modified (heavily) and optimized by Collin Stocks
    bits=int(b)
    assert 64<=bits
    k=bits<<1
    possible=seed|1 # make it odd
    good=0
    while not good:
        possible+=2 # keep it odd
        good=1
        for i in smallprimes:
            if possible%i==0:
                good=0
                break
        else:
            for i in xrange(k):
                test=random.randrange(2,possible)|1
                if RabinMillerWitness(test,possible):
                    good=0
                    break
    return possible
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号