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

prime_count = 1 start_number = 2 number_to_check = 2 while prime_count <= 1000: result = number_to_check % start_number if result > 0: start_number +=1 elif result == 0: if start_number == number_to_check: print(number_to_check) number_to_check +=1 prime_count +=1 start_number =2 else: number_to_check +=1 start_number = 2 how can i modify this code to end at 1000?

OpenStudy (anonymous):

ur first control statement must be a for loop instead of while loop for (int i=1;i<=1000;i++)

OpenStudy (anonymous):

You don't necessarily need to make it a for-loop.

OpenStudy (anonymous):

Hi! I tried this code. It worked well. It stopped at 1000th prime number which is 7919.

OpenStudy (anonymous):

are you answered?

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!
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!