## 13yrsold 4 years ago How do you compute prime numbers

1. kgiax

You check to see if the only number that can divide evenly into it are 1 and itself.

2. dmancine

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.

3. kgiax

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.

4. dmancine

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.