What's wrong on it | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's wrong on it

Can anyone tell what is wrong in this code to find prime numbersy https://www.sololearn.com/discuss/3030793/?ref=app https://code.sololearn.com/c8k5L7Sk66J0/?ref=app

11th May 2022, 7:21 AM
Jude Maria Bevan
Jude Maria Bevan - avatar
3 Answers
+ 1
You need to start with j = 2 and replace "continue" with "break" to figure out whether a number is "not a prime".
11th May 2022, 7:58 AM
Sandeep
Sandeep - avatar
+ 2
Jude Maria Bevan There are a number of problems with your code, but I think you are trying to stop the continuous loop. You have placed continue before j =j+1, which means the code returns to the start of the loop before it increments j. Therefore j is always =1 and your loop never breaks
11th May 2022, 7:48 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Got it Thank you
11th May 2022, 8:20 AM
Jude Maria Bevan
Jude Maria Bevan - avatar