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

Muavia

In PS 1 I can easily generate integers but I can't separate primes from rest of integers.... Any clues?

  • 2 years ago
  • 2 years ago

  • This Question is Closed
  1. AdisA
    Best Response
    You've already chosen the best response.
    Medals 0

    Read carefully pseudo-code in problem set. Wikipedia: "A natural number is called a prime number (or a prime) if it is bigger than one and has no divisors other than 1 and itself." Only odd integers are candidate for prime numbers. Pseudo-code for that you have in the problem set. When you do that, you have candidates for prime numbers. Your next step should be to check if the number is prime. Example: Your number is 5. It's a odd number, so it's your candidate for prime. Next: you check if that number (5) is divisible with 2,3,4. We see it isn't, so the number 5 is prime.

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

    """Example: Your number is 5. It's a odd number, so it's your candidate for prime. Next: you check if that number (5) is divisible with 2,3,4. We see it isn't, so the number 5 is prime.""" When I write divisible in this sentence I mean that the number has no divisors other than 1 and itself.

    • 2 years ago
  3. Rmat1117
    Best Response
    You've already chosen the best response.
    Medals 1

    Note that when people say "divisible" they really mean "divides into evenly, with a remainder of zero". (Recall the x%a formula from lecture 2 and 3). Now as candidate numbers prove to be primes, you need to add them to "collections" of primes. See lecture 3.

    • 2 years ago
  4. jesse.bo
    Best Response
    You've already chosen the best response.
    Medals 1

    and once it passes the test, you need to record that it is the nth prime number so far, incrementing by 1 each time a candidate passes the test.

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

    that's what i already knew guys... i actually wanted exact code that can get me through

    • 2 years ago
  6. jesse.bo
    Best Response
    You've already chosen the best response.
    Medals 1

    there are plenty of working codes here in the study group, I don't see the value in giving the answer outright and deny you the aha! moment when you figure it out yourself. Someone else might though.

    • 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.