// prime or not
import java.io.*;
class ssva30
{
public static void main(String arg[]) throws IOException
{
int n,i,p=1;
BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
System.out.print("\n\t\t\tChecking the Number is prime or Not");
System.out.println("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.print("\nEnter the Value of N: ");
n=Integer.parseInt(inp.readLine());
for(i=2;i<n;i++)
{
if(n%i==0)
p=0;
}
if(p==0)
System.out.print("\nThis is not Prime Number\n");
else
System.out.print("\nThis is Prime Number\n");
}
}Java
Calculate The Given Number is Prime Number or Not Using Java

Written by
View ProfileSenthilvelan Sambamoorthy
Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.
