I've got everything working on ps1, except my program doesn't find 2 as a prime. My brain is spent - can someone explain what I'm doing wrong?
primesFound = 1
testMe = 1
while primesFound < 1000:
for divisor in range(2,testMe):
remainder = testMe % divisor
if testMe%2 == 0: break
if remainder == 0:
prime = False
if divisor == testMe-1:
print str(testMe) + " is a prime number."
primesFound = primesFound + 1
testMe = testMe + 1
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
edit = the "if testMe%2 == 0: break" shouldn't be in there, I was just testing it.
I understand that it's skipping 2 because the remainder works out to 0 on the first loop, but when I change the range to start at 1, then the entire program doesn nothing.
Can you repost your code using dpaste.com. or attach them?
Actually I got it working... :)
Should I still post it?
Not the answer you are looking for? Search for more explanations.
No but next time when you post your code either attach a file or put it on dpaste.com and post the link because when you just post it in the message when we copy it to a file the indentations are all gone and it all goes on one line.
That's odd, it copies perfectly for me.
Maybe it's because I'm running linux. I'm not sure though.
I just want to add that in Firefox if you highlight the script you want to copy, right-click and select "View Selection Source", a window will pop up with the script text already highlighted. You can then copy from that and paste into Python and it will keep the proper formatting.
If you don't use Firefox, perhaps there's a similar function in your browser. Just wanted to share in case you find it useful.
Thanks yea I knew about the source but I would of never thought to use it for that very creative haha