Prime Number Program in Java

By: Prem Tiwari | Last Updated: | In: Java Programming


This is a simple Java program to find the prime number. A prime number is a number which is greater than 1 and only divisible by 1 or itself. Following is the first 10 prime numbers:

Prime Number Program in Java

In this program, I have taken number as variable to hold the number which will be checked whether it is a prime number or not.

Copy the below java program and execute it with the help of Java compiler.

Output

11 is prime number

Share this post!


About: Prem Tiwari

Prem Tiwari is the founder of FreeWebMentor.com and also a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies.


Tags: , , , , , , , , ,