能不能尽早做出来,这个时间不多

编写程序,求1至1000以内同时被3和7整除的个数(要求用while循环实现)。


a = 1
count = 0
while a<=1000:
    if a%3 == 0 and a%7 == 0:
        count += 1
    a += 1
print(count)
n=1
count=0
while n<1000:
    if n%21==0:count+=1
    n+=1
print(count)

47个


num = 1
count = 0
while num != 1000:
    if num % 3 == 0 and num % 7 == 0:
        count += 1
        num += 1
    num += 1
print(count)

img

count = 0
i = 1
while i<=1000:
    if i%3 == 0 and i%7 == 0:
        count += 1
    i += 1
print("同时被3和7整除的个数:",count,"个")

如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

img