【发布时间】:2013-12-23 07:15:25
【问题描述】:
我有以下代码:
#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
我尝试搜索“for i in”+“变量”等,但找不到任何东西......
我有两个问题:
你会建议我搜索什么?
如何解决这个问题,以便我可以找到任意数字的两个倍数之和?
任何帮助都会很棒。
【问题讨论】:
标签: python-2.7