isPrime

来源:互联网 发布:lee levis 知乎 编辑:程序博客网 时间:2024/06/05 07:14
__author__ = 'gate_007'#encoding:utf-8# import mathfrom  math import sqrtNUM = 50ret = []def isPrime():    for i in range(2, NUM):        PRIME = True        for j in range(2, int(sqrt(i)) + 1):            if i % j == 0:                PRIME = False                break        if PRIME:            ret.append(i)    print retif __name__ == '__main__':    isPrime()

Result:
pydev debugger: process 15169 is connectingConnected to pydev debugger (build 139.1001)[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]Process finished with exit code 0
0 0
原创粉丝点击