【发布时间】:2015-08-26 09:31:48
【问题描述】:
我的代码是:
currentNum = 0
divisible = True
prime = 0
counter = 1
counter2 = 1
counter3 = 0
counter4 = 0
while not counter == 10:
while not counter2 == counter:
currentNum = counter / counter2
while not counter3 == counter:
if currentNum == counter3:
counter4 = counter4 + 1
if counter4 == 1:
divisible = True
counter4 = 0
else:
divisible = False
prime = prime + 1
counter4 = 0
counter3 = 0
counter2 = 1
counter = counter + 1
print(prime)
但由于某种原因,它只在我尝试使用它时显示0.5。
【问题讨论】:
-
你能解释一下它应该做什么。你说它是一个素数查找器,但你想实现什么算法?所有的计数器是怎么回事?
-
不知道你想要实现什么,但你绝对不应该得到分数,你需要
currentNum = counter // counter2