#include<stdio.h>
void main()
{
int a,b,i,p,k,t,n;
scanf("%d",&n); for(t=1;t<=n;t++) {
scanf("%d%d",&a,&b); for(p=a;p<=b;p++)
for(i=1,k=0;i<=p;i++) { if(p%i==0) k++; }
if(k==2)
printf("%d ",p);
} printf("\n"); }
}
check the number is prime or not till square root of that number.
what for? The program is perfect as far as the generation of prime numbers is concerned.
to save time
You don’t need to count the number of divisors, just to say whether there are any. So, to save time: