Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

I am working on problem set 1 and have hit a bit of a wall. Can somebody help?

MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer

SEE EXPERT ANSWER

To see the expert answer you'll need to create a free account at Brainly

What have you tried so far?
primeCounter = 1 numbertoTest = 3 while primeCounter < 1000: for divisor in range (2, numbertoTest): if numbertoTest % divisor == 0: numbertoTest = numbertoTest + 2 else: divisor = divisor + 1 if numbertoTest != 0: primeCounter = primeCounter + 1 numbertoTest = numbertoTest + 2 print numbertoTest
I think you should experiment a bit with how for loops work, the else: divisor = divisor + 1 section doesn't do anything. Also, why are you checking to see if numbertoTest doesn't equal zero? Where and why would your code set it to zero? Both those are tangential to the problem your having though. What's the algorithm you're using? Describe it in as much detail as possible.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Looking at your first if/else loop. If the number is 9. Range will be 2,9. So...9/2 has a remainder. Div + 1. 9/3 = no remainder. so, add 2 to numerator. 11/3 = no remainder. Add 1 to divisor. 11/4 - no rem. 11/5 no remainder, etc, up to 11/10, then no remainder, so go to next IF statement where the counter is increased. Your algorithm is incorrect. You need a command to break the cycle, before you do all the calculations for the entire range of "divisor in range(2,numbertoTest).
I made some typos...please forgive me - so text should be: Looking at your first if/else loop. If the number is 9. Range will be 2,9. So...9/2 has a remainder. Div + 1. 9/3 = no remainder. so, add 2 to numerator. 11/3 = remainder. Add 1 to divisor. 11/4 - rem. 11/5 remainder, etc, up to 11/10, then remainder, so go to next IF statement where the counter is increased. Your algorithm is incorrect. You need a command to break the cycle, before you do all the calculations for the entire range of "divisor in range(2,numbertoTest).

Not the answer you are looking for?

Search for more explanations.

Ask your own question