Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

How do you compute prime numbers

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.

Get this expert

answer on brainly

SEE EXPERT ANSWER

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

You check to see if the only number that can divide evenly into it are 1 and itself.
That's the mathematical definition. As far as writing a program, you know that 1 and itself already divide it, so you check to see that each of 2 through itself-1 DON'T divide it. (You can actually stop before itself-1, but don't worry about that until you get your code working correctly.) And just a hint, first write the code to test if a single number is prime, and test it. THEN write the code that finds multiple primes.
Yeah I was just being a wiseass really. He said "compute" and that could really just be "how do I do it on a calculator". But even if he's asking how do you write a program that does it, the answer is the same: you write code that takes a number and checks to see if it only divides evenly by 1 and itself (though yeah, logically you'd do that in reverse like you said). If he doesn't know how to do that, either he should be more specific so we can answer the question better, or maybe he should just re-read the material/rewatch the lecture. It's way too broad a question, is what I'm nitpicking basically.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Yes, but his name says he's only 13, and I don't remember when I learned about prime numbers, but it's possible he doesn't know. Actually, I didn't read your response as wiseass. I guess I've learned to read things on the web as sincere. Either way, I think he knows what a prime number is now.

Not the answer you are looking for?

Search for more explanations.

Ask your own question