A community for students.
Here's the question you clicked on:
 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
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

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0oops 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.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0my problem is that it won't let me divide by a tuple. any suggestions to get around this problem?

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0You cannot divide by a tuple. You can divide by numbers in a tuple if you like, but tuples are containers, not numbers.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0You might want to try creating a list of primes since nonprimes cannot be divided evenly by primes.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0polpak: 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

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0for number in mytuple: if prime % number == 0: # prime is not prime.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0ooooooooooh tats how you do it thanks
Ask your own question
Sign UpFind more explanations on OpenStudy
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
 Engagement 19 Mad Hatter
 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.