check the number is prime (using java)

 class prime

{

public static void main(String args[])

{

int no=10,count=0;

for(int i=1; i<=no ; i++)

{

if(no%i==0)  // i is the factor of that number

{

count++;

}

}

if(count==2)

System.out.println("prime no");

else

System.out.println("composite no");

}}



Comments

Popular posts from this blog