Python|m~n能被3整除的数之和

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


版权声明:本文为weixin_46499784原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。