PRIME1 - Prime Generator
solution-
#include<stdio.h>
#include<math.h>
int main()
{int t;
long long int l,h,i,flag;
scanf("%d",&t);
while(t--)
{
scanf("%lld%lld",&l,&h);
while(l<=h)
{
flag=0;
for(i=2;i<=sqrt(l);i++)
{ if(l%i==0)
{
flag=1;
break;
} }
if(flag==0)
{ if(l!=1)
printf("%lld\n",l);
}
l++;
}
printf("\n");
}
return 0;
}
Comments
Post a Comment