jam=0
for i in range(101,1000,2):
for j in str(i):
jam+=int(j)
if i % jam==0:
print(i)
This program just shows 137
and this answer is not true. What is the bug?
This loop keeps incrementing jam
and never resets it. jam
quickly becomes greater than 1000, and after that i % jam==0
is guaranteed to be False
. Did you mean to put jam = 0
inside the loop?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.