WHY IT SHOWING TIME LIMIT IN CASE 0

PLEASE CORRECT MY CODE.

Please post your code

import java.util.Scanner; public class PMO { public static void main(String[] argS) { Scanner input=new Scanner(System.in); int t=input.nextInt(); int c=0; while(c<t) { int sum=0; int n1=input.nextInt(); int n2=input.nextInt(); int n,temp,i,a,b=0; while(n1<=n2) { n=n1; temp=n/2; for(i=2;i<=temp;i++) { a=n%i; if(a==0) b=1; } if(b==0&n!=1&n!=0) { sum=sum+1; } n1++; b=0; } System.out.println(sum); c++; } } }

Yes, this logic isn’t supposed to work. You should first generate all the primes upto 10 ^6 using Sieve of Eratosthenes and then proceed.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.