Not running for one test case , i m not getting it

import java.util.Scanner;

public class PrimeNo {

public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int temp=0;
	for(int i=2;i<=n-1;i++)
	{
		if(n%i==0)
		{
			temp=temp+1;
		}
	}
	if(temp==0)
	{
		System.out.println("prime no");
	}
	else
	{
		System.out.println("not a prime no");
	}

}

}

Hey @gauravbora945
your code is absolutely correct by concept. It’s just that when the number is not prime then you have to print Not Prime as the output instead of Not a prime number . same for prime

Change your code as

System.out.println("Prime")

System.out.println("Not Prime")

Hope this helps.
Please mark your doubt as resolved and rate as well :slight_smile: