+ 2
I don't why this code output the numbers more time.If I change the code it raises the error.can anybody solve this problem.
Prime number in given intervals https://code.sololearn.com/c87FRe03Q6Lc/?ref=app
4 RĂ©ponses
+ 4
Instead of if-else, try using a for-else clause in inner loop
for:
if:
break
else:
print()
+ 3
Thanks guys problem solved
+ 2
Thanks for your answers
+ 1
á·á.áá§áŽáá in nested loop, you are printing that much times the number is not completely divisible(remainder!=0) by number less than it.
So lets you have 5
Then
5%2!=0 #print 5
5%3!=0 #print 5
5%4!=0 #print 5
So now you get the issue in the code...
Solution:
Set a flag which will keep track if nested loop is broken or not.
If it broke means no prime otherwise prime...