A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

Hi, I have been working on the 1st problem of ps. 1 can someone tell me what is wrong with my code, I can't get it to work. Thanks. y=7 prime=3 t=3 while prime<1000: if y%t==0: y=y+2 if y%t>0 and t<(1/2)*y: t=t+2 if y%t>0 and t==(1/2)*y: t=3 y=y+2 prime=prime+1

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    What is % do?

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    it gives you the remainder

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Oh ok.

  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    What happens if y = 53 and t = 27?

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    i changed that and now it gives me a number but it isn't prime and it is far from the 100th prime.

  6. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Getting it all in one while loop gets pretty complicated. If you can do it then great, but it wont look pretty. I looked it up online and I saw people split it up into a function and function or a function and while loop. For example- try splitting it up into - findPrime(number) function: code while count<1000 code Here is a website that really helped- http://pythonism.wordpress.com/2008/05/04/looking-at-prime-numbers-in-python/

  7. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.