[英]A program that displays the three-digit numbers that can be divisible by the sum of the first number numbers
jam=0
for i in range(101,1000,2):
for j in str(i):
jam+=int(j)
if i % jam==0:
print(i)
這個程序只顯示137
而這個答案是不正確的。 什么是錯誤?
這個循環不斷增加jam
並且永遠不會重置它。 jam
很快變得大於 1000,之后i % jam==0
保證為False
。 您的意思是將jam = 0
放入循環中嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.