1
我正在写一个程序来打印3
或5
的倍数之和,小于1000
。我正在使用算术级数来做到这一点。我的代码是:int object not callable error(sum of multiples)
def multiple(x,y):
a=(1000-(1000%x) - x)/x +1
b=(995-y)/y +1
c=(1000-(1000%x*y)-x*y)/x*y +1
Sa=int(a/2(2*x+(a-1)*a))
Sb=b/2(2*y+(b-1)*b)
Sc=c/2(2*x*y+(c-1)*x*y)
Sd=Sa+Sb-Sc
print Sd
当我打电话的功能我得到的错误:
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python27\swampy-2.1.7\MULTIPLE.py", line 23, in multiple
Sa=int(a/2(2*x+(a-1)*a))
TypeError: 'int' object is not callable
请指出错在我的代码。谢谢。
P.S.请原谅我提问的“艺术”。我是Python和StackOverflow的新手,请耐心等待。谢谢!