2024-04-23 11:07:29 发布
网友
这是我查找素数的简单代码
for pt in range(1,100): isp = 1 for ts in range(1,100): if(pt%ts ==0): isp= 0 break if(isp): print(pt)
此错误
文件“/存储/模拟/0/qpython/素数.py“,第3行” 对于范围内的ts(1100): ^ 缩进错误:未缩进与任何外部缩进级别都不匹配
你的语法和逻辑都有错误。你可以试试这个:
for pt in range(2, 100): isp = 1 for ts in range(2, pt): if pt % ts == 0: isp = 0 break if isp: print(pt)
你的语法和逻辑都有错误。你可以试试这个:
相关问题 更多 >
编程相关推荐