找出a-b之间的质数

2015-01-24 0 168
找出a-b之间的质数
def  prime(b):
    t=b/2
    for i in range(2,t+1):
        if b%i==0:

            break
    else:
        return b

if __name__=="__main__":
    a=input('please input the first number:')
    b=input('please input the next number:')
    list=[]
    for i in range(a,b+1):
       if prime(i):
           list.append(prime(i))

    print 'the prime list is %s'%list

遇见资源网 python 找出a-b之间的质数 http://www.ox520.com/15092.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务