A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

HELP!! I'm stuck on ps1a. here's my code: http://dpaste.com/532527/ my reasoning behind the program is this: give prime the value 1. give even_number the value 2. set up a loop to repeat the process 999 times. add prime and even number to be new value for prime. check to see if prime can be evenly divided by numbers from 2 up to but not including prime. if it can be divided evenly by any number from 2 to but not including prime. keep adding 2 to even number and repeating until prime is not evenly divisible by 2 to but not including prime. after the loop is completed to obtain the prime make

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

    oops my reasoning got cut, here it is is full: give prime the value 1. give even_number the value 2. set up a loop to repeat the process 999 times. add prime and even number to be new value for prime. check to see if prime can be evenly divided by numbers from 2 up to but not including prime. if it can be divided evenly by any number from 2 to but not including prime. keep adding 2 to even number and repeating until prime is not evenly divisible by 2 to but not including prime. after the loop is completed to obtain the prime make even_number equal 2 again. print prime.

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

    my problem is that it won't let me divide by a tuple. any suggestions to get around this problem?

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

    You cannot divide by a tuple. You can divide by numbers in a tuple if you like, but tuples are containers, not numbers.

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

    You might want to try creating a list of primes since nonprimes cannot be divided evenly by primes.

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

    polpak: what i was trying to do was, as you said, divide by the numbers contained in the tuple. I just can't figure out how to do it

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

    for number in mytuple: if prime % number == 0: # prime is not prime.

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

    ooooooooooh tats how you do it thanks

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

    thats*

  9. 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.