class PrimenumExample{
public static void main(String args[]){
int j,m=0,f=0;
int n=7;//Number which we want to check
m=n/2;
for(j=2;j<=m;j++){
if(n%j==0){
System.out.println("Number is not prime");
f=1;
break;
}
}
if(f==0)
System.out.println("Number is prime");
}
}
public static void main(String args[]){
int j,m=0,f=0;
int n=7;//Number which we want to check
m=n/2;
for(j=2;j<=m;j++){
if(n%j==0){
System.out.println("Number is not prime");
f=1;
break;
}
}
if(f==0)
System.out.println("Number is prime");
}
}
No comments:
Post a Comment