m,n=[int(s) for s in input("输入m、n的值:").split() ]
tot=0
for i in range(m,n+1):
if i%3==0:
tot+=i
print(tot)
输入:1 10
运行结果:
输入m、n的值:1 10 3 9 18 Process finished with exit code 0

m,n=[int(s) for s in input("输入m、n的值:").split() ]
tot=0
for i in range(m,n+1):
if i%3==0:
tot+=i
print(tot)
输入:1 10
运行结果:
输入m、n的值:1 10 3 9 18 Process finished with exit code 0