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
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.
my problem is that it won't let me divide by a tuple. any suggestions to get around this problem?
You cannot divide by a tuple. You can divide by numbers in a tuple if you like, but tuples are containers, not numbers.
You might want to try creating a list of primes since nonprimes cannot be divided evenly by primes.
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
for number in mytuple: if prime % number == 0: # prime is not prime.
ooooooooooh tats how you do it thanks
thats*
Join our real-time social learning platform and learn together with your friends!