如打印1-100中可被2和3整除的總和最一般的情況可能这样写
thesum=0
for x in xrange(101):
if x %2==0 and x%3==0:
thesum+=x
print thesum
回复内容:
不是j
+/ (#~ (0=2&|) *. (0=3&|)) 1+i.100
scala:6 to 100 by 6 sum不妨考虑一下可读性吧
sum(range(6,101,6))
1 to(100) aslist select(%6==0) sum
haskell :sum [x | x