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.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your **free** account and access **expert** answers to this and **thousands** of other questions.

I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your **free** account and access **expert** answers to this and **thousands** of other questions

Not only odd - 2 too. And up to a certain limit, which is way lower than the number you test.

@Beeb - The assignment doesn't require that you generate only odd numbers to test, it merely suggests it. Of course, testing only odd numbers would be more efficient. However, ps1b will require that 2 be included in the list of primes to get a correct answer.
@jaron - I've attached my ps1a, if you'd like to take a look. It is very inefficient, but it works.

Opps, sorry for the double post.

from an algorithmic efficiency point of view I find the filtering out of the evens quite a bonus and the 2 as a gain for not doing so not very important. One can just add it via append (see below)since it is an obvious simple prime case...and this is a program not a math course. Plus it makes the filtering a tad easier and the running through way more efficient.
Here is my old piece of code....
# prime.py
# finds primes up to 1000
list=[]
for k in range(1001): #since it would otherwise just go to 999 due to range
if ((k%2)==1): #takes the odd ones
for j in range(2,k+1): #loops through all variables from 2 to k
if( ((k%j)==0) and j

i tried it and it didn't work ...it gave me only 2 many times and didn't stop

ok thanks a lot. which lectures are you in or you finished python

I'm on lecture 22. But just started to work on the problem sets.

ok good luck...i thought we can study together but its way too far. i am in lecture 4 :D