我有以下代碼:的Python +可變
#Euler Problem 1
print "We are going to solve Project Euler's Problem #1"
euler_number = input('What number do you want to sum up all the multiples?')
a = input('Insert the 1st multiple here: ')
b = input('Insert the 2nd multiple here: ')
total = 0
for i in euler_number:
if i%a == 0 or i%b == 0:
total += i
print "Sum of all natural numbers below 'euler_number' that are multiples of 'a'"
print "or 'b' is: ", total
,出現以下錯誤:
Traceback (most recent call last):
File "euler_1.py", line 10, in <module>
for i in euler_number:
TypeError: 'int' object is not iterable
我試圖尋找「爲我在「+」變量「,和其他種類,但找不到任何東西...
我有兩個問題:
你會建議我搜索什麼?
我該如何解決這個問題,以便我可以查找任意數字的兩個倍數之和?
任何幫助將是偉大的。
謝謝。這確實奏效! –