+ 1
Please why is this code running into an infinity loop .
https://code.sololearn.com/W244YFWjsoIi/?ref=app please could you help me point out the problem and correct it using the same principle I'm trying to find out the first 10 prime numbers
35 Respuestas
+ 2
The variable count is never decreased in value, inside the loop.
+ 2
move line 3 isPrime=true; inside while loop to line 5 so it is always true at the beginning of the loop.
+ 2
mine runs. Did you kill SoloLearn process and restart? Sometimes it gets messed up running bad programs and must be restarted to run anything afterwards,
+ 2
when you have your infinite loop or any broken code, output debug statements of everything you can think of. the more data you see of what is happening the easier it is to fix.
+ 2
console.log(limit+" "+isPrime+" "+count); at top of your while loop would have shown limit going up others not changing.
+ 2
use this server: https://discord.gg/MEjFNcC
+ 2
click on link and it should take you to right place. I had Discord account before linking server and that is all I did.
+ 2
I DM did you get
+ 1
This is why code layout is so important.
I've laid out your code more neatly (and changed nothing else).
Can you find the problem now? If not, I can tell you.
https://code.sololearn.com/WzPPo5114D15/#js
+ 1
once isPrime is false it can never become true.
+ 1
Sir John please what can I do to be a great coder.. or what can I do to be competent on the average
+ 1
The more errors you fix or understand the fixes others give you; The less issues you will have in the future. Practice everything in small pieces at a time. Prove a piece does what you want before expanding it to the next. The more you do the easier it will get.
+ 1
Discord is my only social app.
+ 1
create account and I'll DM you
0
no bro except that I'm dividing by 0 and making the remainder 2 for it to be false
I'm confused as the codeplayground isn't responding
0
please help me out
0
in details pls
0
please can you rewrite yours
0
Xan please could you help me out
0
Sir John please could you explain using a code.. I'm a newbie