Untitled

mail@pastecode.io avatar
unknown
plain_text
8 months ago
591 B
2
Indexable
Never
import java.util.Scanner;
public class primea
{    
public static void main(String args[])
{    
int i,m=0,a=0;
Scanner sc=new Scanner(System.in); 
System.out.println("Enter the number to be checked");     
int n=sc.nextInt();  
m=n/2;      
if(n==0||n==1)
{  
System.out.println(n+" is not prime number");      
}else
{  
for(i=2;i<=m;i++)
{      
    if(n%i==0)
	{      
     System.out.println(n+" is not prime number");      
     a=1;      
     break;      
	}      
   }      
   if(a==0)  {
		 System.out.println(n+" is prime number"); }  
  } 
}    
}   
Leave a Comment