0
problem in python please help
https://code.sololearn.com/cEOUCR3E27aT/#py Can anyone tell me why are the repetition coming?/
7 Answers
+ 1
What you are doing is printing the factors of a given numberđ€
+ 1
Youre getting the repetition from your first âforâ loop. Think, each for loop it has to run through all the numbers, and there is no need for 2 loops. Simplify your loop to this, and give it a try.
for i in range(2,num+1):
if num % i == 0:
print(i)
+ 1
Beau thats just gonna print out the factors of the number (ie. The numbers that can divide into it with no remainder)
+ 1
Thank you people .......thank you for your support......i got the answer
+ 1
Are you using Sieve of Erastothenes?
0
Thomas Williams, i agree. I did see at the top of the code it says âto print prime numbersâ, but that code is missing a couple lines to acheive that. My answer would have been different if he asked why hes not getting primes. But, to answer why hes getting repetition with the code presented, is why i gave that answer:)
0
đđŒthe second for loop basically caused his code to repeat a number of times