计算300到600之间包括300和600既能被3又能被5整除的数字的个数。【1】i=300while 【2】 if i3==0 【3】 i5==0 result+=1 【4】 #使用复合算术运算符+=、-=、=、=等print300到600之间有个既能被3又能被5整数的数字formatresult
【2】i<=600:
完整代码:
result = 0 i = 300
while i <= 600: if i % 3 == 0 and i % 5 == 0: result += 1 i += 1
print("300到600之间有{}个既能被3又能被5整除的数字".format(result))
原文地址: https://www.cveoy.top/t/topic/hhmX 著作权归作者所有。请勿转载和采集!