相关疑难解决方法(0)

Python中的简单Prime生成器

请问有人请告诉我这段代码我做错了什么?无论如何,它只是打印'计数'.我只想要一个非常简单的素数发生器(没什么特别的).

import math

def main():
    count = 3
    one = 1
    while one == 1:
        for x in range(2, int(math.sqrt(count) + 1)):
            if count % x == 0: 
                continue
            if count % x != 0:
                print count

        count += 1
Run Code Online (Sandbox Code Playgroud)

python primes

33
推荐指数
7
解决办法
11万
查看次数

标签 统计

primes ×1

python ×1