how to generate prime numbers

  • Thread starter Thread starter ritesh.raghuvanshi
  • Start date Start date
R

ritesh.raghuvanshi

can anybody help me in this...?
i want to generate prime numbers starting from zero to the number
entered by user...
quick please....
 
can anybody help me in this...?
i want to generate prime numbers starting from zero to the number
entered by user...
quick please....

This sounds like homework to me. On this group, we don't usually
answer homework questions directly, but help you to work the answer
out for yourself.

So, how far have you got already? What's not working?

Jon
 
can anybody help me in this...?
i want to generate prime numbers starting from zero to the number
entered by user...
quick please....
Look up the Sieve of Eratosthenes.

rossum
 
can anybody help me in this...?
i want to generate prime numbers starting from zero to the number
entered by user...
quick please....

Funny, I did the same just the other day. It's quite easy.

First of all, you can't start from zero, you have to start from one.

Just loop throught the numbers from one to the entered number. Store the
prime numbers in a list, and loop throught the list for each number
checking if any of them is evenly dividable by the number.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top