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…

6 years ago
OpenStudy (anonymous):

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

6 years ago
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.

6 years ago
OpenStudy (anonymous):

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

6 years ago
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?

6 years ago
Similar Questions: