求素数的方法实际可运行么?
Topic sourcedef p(): def z(): n=1 while True: n += 2 yield n def sx(n): return lambda x: x % n > 0 yield 2 i=z() while True: n = next(i) yield n i = filter(sx(n),i)
for a in p(): if a>100: break print(a)
能用啊
- 1
def p(): def z(): n=1 while True: n += 2 yield n def sx(n): return lambda x: x % n > 0 yield 2 i=z() while True: n = next(i) yield n i = filter(sx(n),i)
for a in p(): if a>100: break print(a)
能用啊
贝司特曼
我完全复制文中的代码,但是电脑一运行就卡死。