Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

paul99santos Group Title

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), -----------------------------------------------------------------

  • 2 years ago
  • 2 years ago

  • This Question is Open
  1. VirPriscus Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    I've run it, and it does what it's supposed to, namely, produce prime numbers less than 410.

    • 2 years ago
  2. paul99santos Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    My question is there any efficient or better source code than this?

    • 2 years ago
  3. VirPriscus Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

    • 2 years ago
  4. paul99santos Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

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

    • 2 years ago
  5. bwCA Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    http://dpaste.com/750733/

    • 2 years ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.