0

why it has no output?

j=1 s=0 for i in range(2,1001): while j < i: if i%j==0: s=s+j j+=1 if i==s: print(s)

26th Oct 2018, 11:25 AM
Gaskell Broderick
Gaskell Broderick - avatar
1 ответ
+ 1
Assuming you want to print all the perfect numbers between 2 and 1000... Put s=0 j=1 Inside the for loop (at the beginning), and not before it. Then it should work. You need to reset them for each i 😊
26th Oct 2018, 12:34 PM
Kishalaya Saha
Kishalaya Saha - avatar