Ask your own question, for FREE!
Computer Science 48 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
Breathless: womp
21 minutes ago 0 Replies 0 Medals
Breathless: yo who wanna match pfp?
23 minutes ago 11 Replies 1 Medal
Ylynnaa: This was long time ago lmk if u fw itud83dude1d
4 hours ago 17 Replies 2 Medals
abound: Wow question cove really fell off
6 hours ago 6 Replies 1 Medal
ayden09: chat i love black pink hehe i like jones to
5 hours ago 20 Replies 2 Medals
kamani7676: help
1 day ago 5 Replies 1 Medal
kamani7676: Help
1 day ago 76 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!