I'm working on PS1a. While I have a general understanding of what I need to do, I'm a little lost as far as beginning my code. My first thought was to define what a prime number is in Python. I was thinking along the lines of something like: pn= a/a == 1 and a/1 == a These would be the two rules for primes: divisible only by 1 and itself. I'm stuck on getting the proper code going though. Can someone point me in the right direction? Also, is there a reference sheet explaining what Python key words, commands, etc all do? Thanks!
Rather than focusing on what a prime number is, it may help to focus on what a prime number isn't. I realize that it sounds kind of funny. What I mean is, assume that the number is prime, then try to disprove the assumption. Hopefully I can explain: For example, try getting a list of numbers together and checking to see if there are any numbers (you only need to check numbers less than the candidate) that will divide with a remainder of 0. If so, they are not prime numbers. If you exhaust checking what a prime number isn't, then you know you have a prime number. I hope I didn't just confuse you more. Anyway, I find the official Python documentation very useful: http://docs.python.org/index.html.
That kind of helps. A big link I'm missing is that from lectures 1-2 and the reading, I'm not understanding how I'm supposed to come up with a program that does this. The lectures are kind of vague and leave lots of holes to be filled for me. Can you send me that link again? I can't get it to open. Thanks!
Sorry, a period got pulled into the link last time: http://docs.python.org/index.html
Join our real-time social learning platform and learn together with your friends!