Here you will get the program for prime number in java.
A number is prime in the event that it is distinct by 1 or itself.
For instance 2, 3, 5, and so on are prime numbers while 4, 6, 8, and so on are not prime.
Program for Prime Number in Java
class prime
{
public static void main(String...s)
{
int n,i;
n=Integer.parseInt(s[0]);
for(i=2;i<n;++i)
{
if(n%i==0)
break;
}
if(i==n)
System.out.println("\nNumber is prime");
else
System.out.println("\nNumber is not prime");
}
}
Output