/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
try{
Scanner sc = new Scanner(System.in);
int t=sc.nextInt();
int k=0;
for(int i=0;i<t;i++)
{
int n = sc.nextInt();
if(n==1)
System.out.println(“NO”);
for(int j=2; j<n/2 ;j++)
{
if( n%j == 0)
{
k++;
break;
}
The output should be “yes” or “no”. Here is the logic for a prime number:
public static boolean isPrime(int n)
{
boolean prime = true;
for (int i = 2; i <= Math.sqrt(n); i++)
{
if (n % i == 0)
{
prime = false;
break;
}
}
return prime;
}