java program to check prime number

Previous
Next

This is easy question. It may not be asked you directly, but you can use this program to create many other complex program.
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.

Program logic:

If any number which is not divisible by any other number which is less than or equal to square root of that number, then it is prime number.
Lets create java program for it:

Run above program, you will get following output:

Please go through java interview programs for more such programs.

Previous
Next

Join Our News Letter – Stay Updated

Subscribe to Awesome Java Content.




One Response

  1. Francesco May 7, 2015

Add Comment

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.
You can like our facebook page Java2blog