20170522-Python作业

作者: Jerome_vae | 来源:发表于2017-05-22 23:18 被阅读73次

    ##  求素数

    # By 威威

    # 20170522

    primeList = [1]

    for i in range(2, 101):

    for j in range(2, i+1):

    if i%j == 0:

    count = j

    if count != i:

    break

    else:

    primeList.append(i)

    break

    else:

    continue

    print(primeList)

    得到的结果是:

    [1, 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]

    啦啦啦啦

    相关文章

      网友评论

        本文标题:20170522-Python作业

        本文链接:https://www.haomeiwen.com/subject/xdaixxtx.html