Prime Number Program in Java

 In this post let’s how to find the given number by the user is prime or not. Usually, the prime number is a number which is divisible by one and by itself.

Note: 0 and 1 are not prime numbers. The 2 is the only even prime number because all the other even numbers can be divided by 2.


 2)Input the number from the user.
 3)Go on dividing the number starting from 2 to one unit lesser than the given number.
 4)Check whether the remainder of any number is zero.
 5)If the remainder is not zero continue the loop.
 6)If the remainder is zero display the given number is not prime.
 7)When the loop gets over the display that the given number is prime.

Code goes here: