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.
I think it's very nice, but, maybe you could change n%x == 0 to n % x == 0 which improves readability. It's part of the python style guide: http://www.python.org/dev/peps/pep-0008/
it works great, it will find primes less than 10000. If your search criteria was different or changing you would have to guess what the limit would be in line 2, or know the answer b4 hand. could you rewrite it to find just the 2000th prime? without having to guess how big that number is?
Something like this? http://codepad.org/J67EOiDK
you find only prime which is highest in up to 2000 but not 2000th prime
@Tomas.A ah, I misread the question.
cool. thanks all!
I liked this line. for n in range(3, 10000, 2): Using the optional, third arg like that saved you filtering out all the evens afterwards. It was clever to spot that.
@michalmichalski did you manage to write program like @bwCa said?
question guys...for this formula, line of for X in range (3,n), i made it: for x in range(3, int(sqrt(n))+1: is this a faster way to run the program
My recommendation would be to try and make this program more useful. Try and make it into a function that has input n and output of the nth prime.
... yep you only really have to check up to the square root - but that's just an optimization
@ Tomas, no I didnt write it yet - but I ll give it a try. @ earthbound() - good suggestion with the sqrt, thnks thanks for yr comments!