問題1項目歐拉 必須返回233168 將返回266333項目歐拉#1在Python
我不希望使用不同的方法,我想知道爲什麼這個代碼不作爲是工作,從我做的調試看起來,我期望看到的所有內容都在那裏。
numArray = []
a = 0
b = 0
total = 0
totala = 0
totalb = 0
#numArray a and b were for testing purposes to make sure array was correct length
numArraya = []
numArrayb = []
while a < 1000:
numArray.append(a)
numArraya.append(a)
a += 3
#expecting to get 334, returns 334
#print (len(numArraya))
while b < 1000:
numArray.append(b)
numArrayb.append(b)
b += 5
#expecting 200, returns 200
#print (len(numArrayb))
#for numa in numArraya:
# totala += numa
#print (totala)
#for numb in numArrayb:
# totalb += numb
#print (totalb)
for num in numArray:
total += num
print (total)
謝謝!我感到很傻,我正在用10的例子來測試它,並得到他們得到的結果,當它達到更高的數字時變得非常困惑。 – user2100714