Can some1 tell me whats wrong with this answer for 1a? Cheers pprime = 5 primen = 3 fdiv = 2 while primen<1001: if (pprime%fdiv == 0): pprime = pprime +2 if (pprime %fdiv>0) and (fdiv<(pprime/2)): fdiv=fdiv +1 else: print pprime print primen pprime= pprime +2 primen= primen +1
edit, just had a quick scan and picked some errors out however stil not right, here: pprime=5 #pprime is potential prime number primen=3 #associated prime number, where 2 is 1, and 3 is 2. fdiv=2 #first division while primen <1001: if (pprime%fdiv == 0): pprime=pprime + 2 if (pprime%fdiv>0) and (fdiv <=(pprime/2)): fdiv=fdiv+1 else: print pprime print primen primen=primen+1 pprime=pprime+2 fdiv=2 it goes through the cycle but must pickup some none prime numbers, as the 1000th coming up is not right.... going to sleep on it as i havent slept for 24 hrs and cant be good, cheers
You're exactly one line away from being finished. When a pprime turns out to not be prime, what do you want to start dividing the next pprime by?
oh my god, when i got up today i realised after reading your comments, i wrote everything down and realised my mistake when gettin to the number 9 as you can probably tell why, all done now, might get a little creative and try and get the user to input which prime they wish to see andcall just that one back (trying to use nothing more then whats being taught so far), as iv done my 2 lessons for the week, and i want it to really sink in and not rush. Somnamniac, im very greatful for the help!!! your a lifesaver! Just got to figure how to understand part b now haha,
Join our real-time social learning platform and learn together with your friends!