Ask your own question, for FREE!
Computer Science 37 Online
OpenStudy (anonymous):

Ok, sean, thanks for that. I realized the mistake just after i posted the question. so here is my modified code, which just runs and runs and runs, in loops, goes up to the highest prime under 10000, then goes back to two. i just wanna make it stop at the 1000th prime. how do i do that? http://codepad.org/SANjfhZ9 @MIT 6.00 Intro Co…

OpenStudy (anonymous):

is there some function, say 'print x number of times' or something?

OpenStudy (anonymous):

Try thinking about the program as having two variables that will increase : a primeCounter and a candidate to be tested. Then your while loop is simply while primeCounter < 1000: do the following. Within the while loop you need to test if your candidate is prime. If it is, candidate and primeCounter increase, if it isn't increse your candidate and try again. Does that help? I would get rid of line 5 of your code and try to figure out another way to approach it.

OpenStudy (anonymous):

while x is less than 1000 do sompthing If condition met x = x + 1 When x hits 1000 it'll stop

OpenStudy (anonymous):

In your program what are count and n? Inside your while loop add a print statement that prints what count is (and a message that says it's count). Inside the first for loop add a print statement that prints n and count (and some text so you clearly know which is which). Is that the output you expected?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
ARTSMART: Art!
1 hour ago 4 Replies 3 Medals
Jasonisyours: What were the key causes of the French Revolution in 1789?
2 hours ago 2 Replies 4 Medals
PureSoulless: Why is the word "Pedophile" always censored in yt vids?
1 day ago 3 Replies 0 Medals
Jalli: What's 58x3634u00b07
19 hours ago 6 Replies 3 Medals
arriya: who wanna play roblox
1 day ago 5 Replies 1 Medal
brianagatica14: Any artist on here?
3 days ago 7 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!