Well I programmed this
#include<stdio.h>
#include<stdlib.h>
int main(){
int initial;
int first;
int sec;
int i,j;
scanf("%d",&initial);
for(i=0;i<initial;i++){
scanf("%d",&first);
scanf("%d",&sec);
for(j=first;j<=sec;j++){
if(j==1)
continue;
if((j==2)||(j==3)||(j==5)||(j==7))
printf("%d \n",j);
if((j%2!=0)&&(j%3!=0)&&(j%5!=0)&&(j%7!=0))
printf("%d \n",j);
}
}
return 0;
}
It is based on the sieve of Eratosthenes, it works well for several testaceses i tried, but the judge says that the answer is wrong. This happens because the program is wrong or because of the input-output method I use.