Ace school

with brainly

  • Get help from millions of students
  • Learn from experts with step-by-step explanations
  • Level-up by helping others

A community for students.

Assignment #1 Computing Prime Numbers Hi, I made a program from Assignment #1 Computing Primes Number, I don't know if there is any better program than this? Source code->http://pastebin.com/91Y5WEnL The Source Code: ------------------------------------------------------------------ for candiPrimes in range(2,410): #Test Primes Numbers from 2 to 410 divisor = 1 NumOfReTimes = 0 #Count how many remainder 0 will show up while (divisor<=candiPrimes): '''Analogy: Numbers start from 2 / N times if two remainder 0 will show up and the number is Prime''' if candiPrimes % divisor == 0: NumOfReTimes += 1 divisor += 1 if NumOfReTimes == 2: #test if two remainder 0 did show up print ' ' + str(candiPrimes), -----------------------------------------------------------------

MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
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.

Join Brainly to access

this expert answer

SEE EXPERT ANSWER

To see the expert answer you'll need to create a free account at Brainly

I've run it, and it does what it's supposed to, namely, produce prime numbers less than 410.
My question is there any efficient or better source code than this?
The only real improvement I can think of is that you don't need divisor to come all the way up to candiPrime. You only really need to go up to the sqrt of candiPrime.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Please post your source code to http://pastebin.com and copy/paste you're URL here.
http://dpaste.com/750733/

Not the answer you are looking for?

Search for more explanations.

Ask your own question