Program to find prime number in java
class prime{
public static void main(String []args){
int num=6;
int fac=0;
for(int i=1;i<=6;i++)
{
if(num%i==0)
fac++;
}
if(fac==2)
System.out.println("Is a prime no");
else
System.out.println("Not a prime no");
}
}
class prime{
public static void main(String []args){
int num=6;
int fac=0;
for(int i=1;i<=6;i++)
{
if(num%i==0)
fac++;
}
if(fac==2)
System.out.println("Is a prime no");
else
System.out.println("Not a prime no");
}
}
No comments:
Post a Comment