用python用while语句写1000以内能被5和9整除的数和个数
i=0
s=0
cnt=0
while i<=1000:
if i%45==0:
s+=i
cnt+=1
i+=1
print(s)
print(cnt)
i=1
cnt=0
while i<=1000:
if i%5==0 and i%9==0:
print(i,end=' ')
cnt+=1
i+=1
print()
print(cnt)
res = []
for i in range(1,1000):
if i % 5 == 0 and i % 9 == 0:
res.append(i)
print('能被5和9整除的数:',res)
print('能被5和9整除的个数:',len(res))