package topstechnology;import java.util.*;
public class primenumber {
public static void main(String []args)
{
Scanner sc = new Scanner(System.in);
int i,n,res;
boolean flag=true;
System.out.println("Enter the No.");
n = sc.nextInt();
for(i=2;i<=n/2;i++)
{
res = n%i;
if(res==0)
{
flag =false;
break;
}
}
if(flag)
System.out.println(n + " is Prime Number");
else
System.out.println(n + " is not Prime Number");
}
}
OutPut
0 comments:
Post a Comment