+ 6
Need help
Why this code that must find prime nubers from 3 to 100 includes 95 in the list? Please tell me what I'm doing wrong!! https://code.sololearn.com/ca4yn2obWt7f/?ref=app
4 Respostas
+ 6
I found your mistake, it's in line 14
You only set the divisor b to 2 if you found a prime number as it is inside the if block. You need to put the b = 2 back by 3 spaces to reset the divisor also after every no-prime number as well.
It starts at 93/30 with 93%30 = 0 and the b goes on with 31-95 but b has to be 5 to show that 95 is no prime number.
Hope you got me 😅
+ 6
My pleasure 😉
Also check out my 2 prime number codes 😇
https://code.sololearn.com/cX993MGYxOm5/?ref=app
https://code.sololearn.com/cvwyH0uCpJjN/?ref=app
+ 4
Thank you a lot! Now it works
+ 2
Looking into it...
Maybe try adding a 3rd variable? Maybe it'll work, maybe not. I've seen a lot with different methods, yours seems quite unique.