program for prime number in java


Founder of Java Engineering Programs. Follow me on Google+ ,Linked in.

You may also like...

1 Response

  1. Alex says:

    this is the question for pupil…:-)
    1. You have to know that it is not necessary to check to 23, rather you have to check to sqrt(23) i.e. to 4. This is simple mathematics.
    2. You have to replace while(i<=prime_number-1) with:
    int limit = Math.sqrt(prime_number);
    3. That is all…:-)

Leave a Reply

Your email address will not be published. Required fields are marked *