package numbergame;
import java.util.Scanner;
public class Prime {
public static void main(String[] args) {
int no;
int flag=0;
System.out.println("Enter the no :");
Scanner sc=new Scanner(System.in);
no=sc.nextInt();
for(int i=2;i<=no/2;i++)
{
if(no%i==0)
{
flag=1;
break;
}
}
if(flag==0 && no>1)
System.out.println("Prime no");
else
System.out.println("not prime no");
}
}
import java.util.Scanner;
public class Prime {
public static void main(String[] args) {
int no;
int flag=0;
System.out.println("Enter the no :");
Scanner sc=new Scanner(System.in);
no=sc.nextInt();
for(int i=2;i<=no/2;i++)
{
if(no%i==0)
{
flag=1;
break;
}
}
if(flag==0 && no>1)
System.out.println("Prime no");
else
System.out.println("not prime no");
}
}
0 comments:
Post a Comment